//事先定义好输入输出路径即可
//输入文件路径 inputPath
//输出文件路径 outPaht
File copyFile = new File(inputPath);
File destFile = new File(outPaht);
copyFileChannels(copyFile , destFile );
private static void copyFileChannels(File source , File destFile) throws IOException{
FileChannel inputChannel = null;
FileChannel outputChannel = null;
try{
inputChannel = new FileInputStream(source).getChannell;
outputChannel = new FileInputStream(destFile).getChannell;
outputChannel.transferFrom(inputChannel , 0 , inputChannel.size());
}
finally{
inputChannel.close;
outputChannel.close;
}
}
java copyfile 复制文件
猜你喜欢
转载自blog.csdn.net/qq_40393187/article/details/88877576
今日推荐
周排行