且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用Java将文件从一个目录复制到另一个目录

更新时间:2022-01-19 07:39:43

现在应该可以解决你的问题

For now this should solve your problem

File source = new File("H:\work-temp\file");
File dest = new File("H:\work-temp\file2");
try {
    FileUtils.copyDirectory(source, dest);
} catch (IOException e) {
    e.printStackTrace();
}

FileUtils 类来自 apache commons-io 库,自版本起可用1.2.

FileUtils class from apache commons-io library, available since version 1.2.

使用第三方工具而不是我们自己编写所有实用程序似乎是一个更好的主意.它可以节省时间和其他宝贵资源.

Using third party tools instead of writing all utilities by ourself seems to be a better idea. It can save time and other valuable resources.