-
copyFile
- copy file and rename file
- reserve the file’s last modified date/times(cp -p)
- both src and dest should be file
FileUtils.copyFile(new File("./folderA/a.txt"),new File("./folderB"));
-
copyFileToDirectory
- copy file to dest folder
- dest must be folder, if not exist, mkdirs
FileUtils.copyFileToDirectory(new File("src/main/resources/folderA/a.txt"),new File("src/main/resources/folderB/"));
-
copyDirectory
- copy all files in one folder to another folder
- src must be folder, or throw exception
- for dest folder, mkdirs
FileUtils.copyDirectory(new File("src/main/resources/folderA/"),new File("src/main/resources/folderB/c.txt"));
-
copyDirectoryToDirectory
- copy to dest folder as a subfolder
FileUtils.copyDirectoryToDirectory(new File("src/main/resources/folderA/"),new File("src/main/resources/folderB/"));