I'm a little addicted to the behavior when Java's Files.copy (pathA, pathB) is an error, so make a note of it.
Files.copy (pathA, pathB) is an API that copies file A to file B. When executed, the following error occurs.
Copy error
java.nio.file.NoSuchFileException: \pathA-> \pathB
The file at pathA does not exist! ?? I thought, and when I actually checked the destination folder indicated by the file path, the file existed. Why do I get an error saying "doesn't exist" when it exists! ?? Because I thought, I was addicted to it. .. ..
After trying that trick, check the javaDoc in Files.copy (pathA, pathB) properly. Then
JavaDoc (excerpt) from Files.copy (Path source, Path target)
By default, unless the source and target are the same file (in which case this method exits without copying the file), a copy of the target file if it already exists or is a symbolic link. Will fail.
a. What is the target file path! ?? Finally notice!
When I tried to open the folder indicated by pathB, I found that the last directory in the path did not exist! !!
Confirmation of the existence of the pass is accurate! Understand the API specifications for the API to be used!
I would like to be careful in the future. .. ..
Recommended Posts