java - Atomically move and rename a Path instance - Stack Overflow
If you need it to be atomic, you can use the ATOMIC_MOVE
option:
import static java.nio.file.StandardCopyOption.ATOMIC_MOVE; Files.move(path, targetPath, ATOMIC_MOVE);
Note that this can fail with an AtomicMoveNotSupportedException
if the option is not supported (for example if you are moving a file from a local hard drive to a network location).
Read full article from java - Atomically move and rename a Path instance - Stack Overflow
No comments:
Post a Comment