With John's help, I discovered that /path/to/archive/dir was actually a file. The error message is misleading because it says that /path/to/archive/dir/file.xml not a directory, even if the problem arose from /path/to/archive/dir .
Steps to play on Linux:
1) create the file /tmp/fakedir
touch / tmp / fakedir
2) In Java, execute this piece of code:
Path tempFile = Files.createTempFile("test", "test"); Files.copy(tempFile, Paths.get("/tmp/fakedir/destination.xml"));
You will receive an error message:
Exception in thread "main" java.nio.file.FileSystemException: /tmp/fakeDir/destination.xml: is not a directory at sun.nio.fs.UnixException.translateToIOException(UnixException.java:91) at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) at sun.nio.fs.UnixCopyFile.copyFile(UnixCopyFile.java:243) at sun.nio.fs.UnixCopyFile.copy(UnixCopyFile.java:581) at sun.nio.fs.UnixFileSystemProvider.copy(UnixFileSystemProvider.java:253) at java.nio.file.Files.copy(Files.java:1271) at Test.main(Test.java:17) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Arnaud denoyelle
source share