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

java copy file

    博客分类:
  • JAVA
阅读更多
try {
    // 旧地址
    FileChannel srcChannel = new FileInputStream("srcFilename").getChannel();

    // 新地址
    FileChannel dstChannel = new FileOutputStream("dstFilename").getChannel();

    // Copy file contents from source to destination
    dstChannel.transferFrom(srcChannel, 0, srcChannel.size());

    // Close the channels
    srcChannel.close();
    dstChannel.close();
} catch (IOException e) {
}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics