Summary
Amend the verbiage describing when java.nio.file.Files.move()
will throw the optional specific exception DirectoryNotEmptyException
.
Problem
java.nio.file.Files.move()
throws a DirectoryNotEmptyException
when the source directory contains entries which would be required to be moved if the move is to another file system (device) but this situation is not explicitly described in the javadoc.
Solution
Include in the javadoc for java.nio.file.Files.move()
that it will throw the optional specific exception DirectoryNotEmptyException
in the case where the source directory is non-empty and the target is on another file system.
Specification
--- a/src/java.base/share/classes/java/nio/file/Files.java
+++ b/src/java.base/share/classes/java/nio/file/Files.java
@@ -1391,8 +1391,9 @@
* specific exception)</i>
* @throws DirectoryNotEmptyException
* the {@code REPLACE_EXISTING} option is specified but the file
- * cannot be replaced because it is a non-empty directory
- * <i>(optional specific exception)</i>
+ * cannot be replaced because it is a non-empty directory, or the
+ * source is a non-empty directory containing entries that would
+ * be required to be moved <i>(optional specific exceptions)</i>
* @throws AtomicMoveNotSupportedException
* if the options array contains the {@code ATOMIC_MOVE} option but
* the file cannot be moved as an atomic file system operation.
- csr of
-
JDK-8201407 Files.move throws DirectoryNotEmptyException when moving directory across file system
-
- Resolved
-
- relates to
-
JDK-8246836 (fs) Files.move does not throw DirectoryNotEmptyException when source is non-empty
-
- Closed
-