Forum Discussion
What does this mean? What to write in place of “REPLACE_EXISTING”
Hello indraniria
It means, if the file exists that is getting copied to, it will replace it with what is getting copied from. Here are some other constants that I got when I googled what that meant. You could include them all separated by comma (',') if they would help you with what you are trying to do.
Enum Constants Enum Constant and Description:
ATOMIC_MOVE
Move the file as an atomic file system operation. (did not work in Windows OS)
COPY_ATTRIBUTES
Copy attributes to the new file.
REPLACE_EXISTING
Replace an existing file if it exists.
If you comment the line out
//CopyOption opt = REPLACE_EXISTING
and change the following line from
Files.copy(source, target, opt);
to
Files.copy(source, target);
you will notice when you execute it, it will fail with an error that the file already exists if it does. You would have to write more code to check for the existence of the file if you don't want to use REPLACE_EXISTING.
Related Content
- 9 months ago
- 7 years ago
Recent Discussions
- 5 days ago
- 9 days ago