It is probably FileSystems.getDefault() which is not valid for the net drive.
In the new Path/Paths/Files style:
public void purgeProcessedFile(File xmlFile, String fileDestination) {
Path destFile = Paths.get(fileDestination, xmlFile.getName());
Path directory = destFile.getParent();
if (!Files.exist(directory)) {
Files.createDirectories(directory);
}
if (!Files.exists(destFile)) {
try {
Files.move(xmlFile.toPath(), destFile, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
logger.error(e);
}
} else {
logger.info("File with same name already exists at destination folder: "
+ fileDestination);
}
}
That saying, I would expect the disappeared files to reside on the local computer in a directory created, maybe something like C:/F/My/XML/Data.
Answer from Joop Eggen on Stack OverflowOracle
docs.oracle.com › javase › 7 › docs › api › › › java › nio › file › CopyOption.html
CopyOption (Java Platform SE 7 )
7 ... An object that configures how to copy or move a file. Objects of this type may be used with the Files.copy(Path,Path,CopyOption...), Files.copy(InputStream,Path,CopyOption...) and Files.move(Path,Path,CopyOption...) methods to configure how a file is copied or moved.
Oracle
docs.oracle.com › javase › 8 › docs › api › java › nio › file › CopyOption.html
CopyOption (Java Platform SE 8 )
March 16, 2026 - 8 ... An object that configures how to copy or move a file. Objects of this type may be used with the Files.copy(Path,Path,CopyOption...), Files.copy(InputStream,Path,CopyOption...) and Files.move(Path,Path,CopyOption...) methods to configure how a file is copied or moved.
Oracle
docs.oracle.com › javase › tutorial › essential › io › move.html
Moving a File or Directory (The Java™ Tutorials > Essential Java Classes > Basic I/O)
See Java Language Changes for a ... in Java SE 9 and subsequent releases. See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases. You can move a file or directory by using the move(Path, Path, CopyOption...) ...
Java2s
java2s.com › Tutorials › Java › java.nio.file › Files › Java_Files_move_Path_source_Path_target_CopyOption_options_.htm
Java Tutorial - Java Files.move(Path source, Path target, CopyOption ... options)
In the following code shows how to use Files.move(Path source, Path target, CopyOption ... options) method. //ww w .j av a 2s .c o m import java.io.IOException; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; public class Main { public static void main(String[] args) { Path movefrom = FileSystems.getDefault().getPath("C:/tutorial/Swing_2.jpg"); Path target = FileSystems.getDefault().getPath("C:/tutorial/photos/Swing_2.jpg"); Path target_dir = FileSystems.getDefault().getPath("C:/tutorial/photos"); //method 1 try { Files.move(movefrom, target, StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { System.err.println(e); } } }
Java Tips
javatips.net › api › java.nio.file.copyoption
Java Examples for java.nio.file.CopyOption - Javatips.net
public void renameFile(String newName, boolean overwrite) throws IOException { Path basePath = file.getParent(); CopyOption[] options = new CopyOption[overwrite ? 2 : 1]; options[0] = StandardCopyOption.ATOMIC_MOVE; if (overwrite) { options[1] = StandardCopyOption.REPLACE_EXISTING; } file = Files.move(file, basePath.resolve(newName), options); }
Oracle
docs.oracle.com › en › java › javase › 26 › docs › api › java.base › java › nio › file › CopyOption.html
CopyOption (Java SE 26 & JDK 26)
March 16, 2026 - An object that configures how to copy or move a file. Objects of this type may be used with the Files.copy(Path,Path,CopyOption...), Files.copy(InputStream,Path,CopyOption...) and Files.move(Path,Path,CopyOption...) methods to configure how a file is copied or moved.
Oracle
docs.oracle.com › en › java › javase › 25 › docs › api › java.base › java › nio › file › CopyOption.html
CopyOption (Java SE 25 & JDK 25)
September 15, 2025 - An object that configures how to copy or move a file. Objects of this type may be used with the Files.copy(Path,Path,CopyOption...), Files.copy(InputStream,Path,CopyOption...) and Files.move(Path,Path,CopyOption...) methods to configure how a file is copied or moved.
Javabrahman
javabrahman.com › corejava › copy-move-file-java-one-location-another-examples
How to copy or move a file in Java from one location ...
The class java.nio.file.Files provides static methods for working with files and directories. java.nio.file.StandardCopyOption is an enum implementation of java.nio.file.CopyOption interface which acts as a base interface for providing configurations/options for copying/moving a file.
Oracle
docs.oracle.com › en › java › javase › 22 › docs › api › java.base › java › nio › file › CopyOption.html
CopyOption (Java SE 22 & JDK 22)
July 16, 2024 - An object that configures how to copy or move a file. Objects of this type may be used with the Files.copy(Path,Path,CopyOption...), Files.copy(InputStream,Path,CopyOption...) and Files.move(Path,Path,CopyOption...) methods to configure how a file is copied or moved.
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › nio › file › CopyOption.html
CopyOption (Java SE 17 & JDK 17)
January 20, 2026 - An object that configures how to copy or move a file. Objects of this type may be used with the Files.copy(Path,Path,CopyOption...), Files.copy(InputStream,Path,CopyOption...) and Files.move(Path,Path,CopyOption...) methods to configure how a file is copied or moved.
Tabnine
tabnine.com › home › code library
Code Library - Tabnine
July 25, 2024 - Get the answers and suggestions you need from our AI code assistant. Get started in minutes with a free 90 day trial of Tabnine Pro.
Dev.java
dev.java › learn › java-io › file-system › move-copy-delete
Manipulating Files and Directories - Dev.java
January 25, 2023 - When a method accepts a varargs argument, you can pass it a comma-separated list of values or an array (CopyOption[]) of values. In the following example, the method can be invoked as follows: Empty directories can be moved.
Oracle
docs.oracle.com › javase › 10 › docs › api › java › nio › file › CopyOption.html
CopyOption (Java SE 10 & JDK 10 )
An object that configures how to copy or move a file. Objects of this type may be used with the Files.copy(Path,Path,CopyOption...), Files.copy(InputStream,Path,CopyOption...) and Files.move(Path,Path,CopyOption...) methods to configure how a file is copied or moved.
Top answer 1 of 3
20
You have to either write:
StandardCopyOption.REPLACE_EXISTING
or:
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
Note that you may also try and StandardCopyOption.ATOMIC_MOVE if you can
2 of 3
2
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
.......
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › nio › file › CopyOption.html
CopyOption (Java SE 21 & JDK 21)
January 20, 2026 - An object that configures how to copy or move a file. Objects of this type may be used with the Files.copy(Path,Path,CopyOption...), Files.copy(InputStream,Path,CopyOption...) and Files.move(Path,Path,CopyOption...) methods to configure how a file is copied or moved.
Oracle
docs.oracle.com › en › java › javase › 11 › docs › api › › › java.base › java › nio › file › CopyOption.html
CopyOption (Java SE 11 & JDK 11 )
October 20, 2025 - An object that configures how to copy or move a file. Objects of this type may be used with the Files.copy(Path,Path,CopyOption...), Files.copy(InputStream,Path,CopyOption...) and Files.move(Path,Path,CopyOption...) methods to configure how a file is copied or moved.
W3cubDocs
docs.w3cub.com › openjdk~25 › java.base › java › nio › file › copyoption
CopyOption - OpenJDK 25 - W3cubDocs
An object that configures how to copy or move a file. Objects of this type may be used with the Files.copy(Path,Path,CopyOption...), Files.copy(InputStream,Path,CopyOption...) and Files.move(Path,Path,CopyOption...) methods to configure how a file is copied or moved.