This question already has answers here:
Copying files from one directory to another in Java

(33个答案)


5年前关闭。




将整个目录内容复制到Java或groovy中的另一个目录的方法?

最佳答案

FileUtils.copyDirectory()



为此,这是示例代码

String source = "C:/your/source";
File srcDir = new File(source);

String destination = "C:/your/destination";
File destDir = new File(destination);

try {
    FileUtils.copyDirectory(srcDir, destDir);
} catch (IOException e) {
    e.printStackTrace();
}

10-04 10:08