共计 731 个字符,预计需要花费 2 分钟才能阅读完成。
-
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/"));
正文完