I know about the Methods in FileUtils
, but the FileUtils
won't overwrite.
Also in Files.move("", "", StandardCopyOption.REPLACE_EXISTING)
when the file exists and it's not empty, then the following exception is thrown: java.nio.file.DirectoryNotEmptyException
Sample:
/file1/test1
/file2/test1
How do I merge, move, and overwrite (such as move in windows), /file1/test1
to /file2/test1
?
has java function for this job? I want don't write any method
You could do naive approach with standard java util functions, and nit with Files. First, write a method, what will move and overwrite one file. Before moving, check if the file with this name is is the target folder and delete it, what is simpler, (or open end overwrite content, what is unnecessary complicated). Then, get the list of all files in source folder and apply the method above in the loop.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.