新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
FileChannel進(jìn)行文件復(fù)制
- /**
- * 導(dǎo)入
- * @param urlPath 附件相對(duì)路徑(xml存儲(chǔ)路徑)
- * @param path 項(xiàng)目絕對(duì)路徑
- * @param keyID 要導(dǎo)出信息的keyID
- * @param filepath 導(dǎo)入后路徑
- */
- private static void importCopy(String urlPath, String path, String keyID, String filepath) {
- // 生成目錄
- File f = new File(path + filepath);
- if (!f.exists()) {
- f.mkdirs();
- }
- String filename = urlPath.substring(urlPath.lastIndexOf("/") + 1);
- FileInputStream fi = null;
- FileOutputStream fo = null;
- FileChannel in = null;
- FileChannel out = null;
- try {
- fi = new FileInputStream(path + "/imp/" + keyID + "/" + filename); //源文件
- fo = new FileOutputStream(path + filepath + filename); //導(dǎo)入后文件
- in = fi.getChannel();// 得到對(duì)應(yīng)的文件通道
- out = fo.getChannel();// 得到對(duì)應(yīng)的文件通道
- in.transferTo(0, in.size(), out);// 連接兩個(gè)通道,并且從in通道讀取,然后寫入out通道
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- try {
- fi.close();
- in.close();
- fo.close();
- out.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
【本文是專欄作者張勇波的原創(chuàng)文章,轉(zhuǎn)載請(qǐng)通過(guò)獲取作者授權(quán)】

創(chuàng)新互聯(lián)專注于高港網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供高港營(yíng)銷型網(wǎng)站建設(shè),高港網(wǎng)站制作、高港網(wǎng)頁(yè)設(shè)計(jì)、高港網(wǎng)站官網(wǎng)定制、微信小程序服務(wù),打造高港網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供高港網(wǎng)站排名全網(wǎng)營(yíng)銷落地服務(wù)。
網(wǎng)頁(yè)題目:FileChannel進(jìn)行文件復(fù)制
標(biāo)題URL:http://fisionsoft.com.cn/article/dppsppo.html


咨詢
建站咨詢
