自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

FileChannel進(jìn)行文件復(fù)制

開發(fā) 開發(fā)工具
博主發(fā)表的文章,有的是自己原創(chuàng),有的是這些年本人從網(wǎng)上積累的,方便大家學(xué)習(xí)。

 [[178885]]

  1. /** 
  2.  * 導(dǎo)入 
  3.  * @param urlPath 附件相對路徑(xml存儲路徑) 
  4.  * @param path 項目絕對路徑 
  5.  * @param keyID 要導(dǎo)出信息的keyID 
  6.  * @param filepath 導(dǎo)入后路徑 
  7.  */ 
  8. private static void importCopy(String urlPath, String path, String keyID, String filepath) { 
  9.  // 生成目錄 
  10.  File f = new File(path + filepath); 
  11.  if (!f.exists()) { 
  12.  f.mkdirs(); 
  13.  } 
  14.  String filename = urlPath.substring(urlPath.lastIndexOf("/") + 1); 
  15.  FileInputStream fi = null
  16.  FileOutputStream fo = null
  17.  FileChannel in = null
  18.  FileChannel out = null
  19.  try { 
  20.  fi = new FileInputStream(path + "/imp/" + keyID + "/" + filename); //源文件 
  21.  fo = new FileOutputStream(path + filepath + filename); //導(dǎo)入后文件 
  22.  in = fi.getChannel();// 得到對應(yīng)的文件通道 
  23.  out = fo.getChannel();// 得到對應(yīng)的文件通道 
  24.  in.transferTo(0, in.size(), out);// 連接兩個通道,并且從in通道讀取,然后寫入out通道 
  25.  } catch (IOException e) { 
  26.  e.printStackTrace(); 
  27.  } finally { 
  28.  try { 
  29.  fi.close(); 
  30.  in.close(); 
  31.  fo.close(); 
  32.  out.close(); 
  33.  } catch (IOException e) { 
  34.  e.printStackTrace(); 
  35.  } 
  36.  } 

【本文是51CTO專欄作者張勇波的原創(chuàng)文章,轉(zhuǎn)載請通過51CTO獲取作者授權(quán)】

責(zé)任編輯:武曉燕 來源: 上下求索的Z先生博客
相關(guān)推薦

2023-07-05 07:36:36

SpringJava代碼

2011-09-01 18:54:29

WifiGoodReader

2024-11-20 10:00:00

Python文件讀寫

2010-03-12 19:29:15

python svn腳

2022-08-17 12:35:26

Linux sed編輯器

2024-09-29 16:27:46

Python文件管理

2021-08-30 07:57:26

OpenAttack文本對抗攻擊

2018-03-27 13:33:48

百度

2020-12-31 05:37:05

HiveUDFSQL

2021-03-31 12:41:24

C語言編程語言

2023-11-13 18:37:44

2022-02-14 15:07:48

進(jìn)程FileChanne線程

2023-06-11 17:00:06

2016-11-16 15:05:42

情感分析

2021-10-08 11:45:33

內(nèi)存HeapByteBuf堆內(nèi)

2010-03-23 16:30:47

Python文件復(fù)制

2015-02-02 11:03:12

2021-05-24 06:20:04

Linuxsed命令

2010-02-22 18:04:27

CentOS mpla

2023-11-28 09:00:00

機(jī)器學(xué)習(xí)少樣本學(xué)習(xí)SetFit
點贊
收藏

51CTO技術(shù)棧公眾號