I am trying to move a file from a folder A: "/files/attachments/2000/filename.txt" to folder B: "/files/attachments/trashbin/2000/filename.txt" but I keep getting the exception: FileAlreadyExistsException and the exception output is: "/files/attachments/trashbin/2000".
this is the code:
Path filePath = Paths.get(pathOnNFS.concat(folderPath).concat(Utils.DELIMITER + fileName));
Path trashBinPath = Paths.get(trashBinNFS.concat(folderPath));
try {
Files.createDirectories(trashBinPath);
Files.move(filePath, trashBinPath.resolve(fileName), StandardCopyOption.REPLACE_EXISTING);
}catch(...){}
Can anyone suggest why it is happening? this is the documentation: https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/nio/file/Files.html#move(java.nio.file.Path,java.nio.file.Path,java.nio.file.CopyOption...)