I do java.nio.file.Files.move(path, path.resolveSibling("newfilename"))to rename a directory in Windows 7.
But I get the following exception:
java.nio.file.AccessDeniedException: oldfilename -> newfilename
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:387)
at sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:287)
at java.nio.file.Files.move(Files.java:1345)
What causes this? I am using Java 7. The
target path does not exist before the call Files.move().
UPDATE
From javadoc :
When moving a directory requires that its entries be moved then this method fails
(by throwing an IOException).
My directory is not empty and contains regular files, so maybe this is the reason it cannot be used here? I'm having trouble understanding what “requires his records to be migrated”. When is this so?
source
share