`
wangyun
  • 浏览: 120856 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

复制文件

 
阅读更多
public class FileUtil {

/**
*  复制文件
*  @param from 原文件
*  @param to 目标文件
*/
public static void copyFile(String from, String to)
throws  FileNotFoundException, IOException {
FileChannel
fChannel = new FileInputStream(from).getChannel(),
tChannel = new FileOutputStream(from).getChannel();

fChannel.transferTo(0, fChannel.size(), tChannel);
//或者tChannel.transferFrom(fChannel, 0, fChannel.size());
}
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics