You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2021/01/12 16:10:11 UTC

[GitHub] [commons-io] garydgregory commented on a change in pull request #185: IO-700: provide method overload for moveFile

garydgregory commented on a change in pull request #185:
URL: https://github.com/apache/commons-io/pull/185#discussion_r555848248



##########
File path: src/main/java/org/apache/commons/io/FileUtils.java
##########
@@ -2172,12 +2177,39 @@ public static void moveDirectoryToDirectory(final File src, final File destDir,
      * @since 1.4
      */
     public static void moveFile(final File srcFile, final File destFile) throws IOException {
+        moveFile(srcFile, destFile, true);
+    }
+
+    /**
+     * Moves a file.
+     * <p>
+     * When the destination file is on another file system, do a "copy and delete".
+     * </p>
+     * <p>
+     * <strong>Note:</strong> Setting <code>preserveFileDate</code> to {@code true} tries to preserve the files' last
+     * modified date/times using {@link File#setLastModified(long)} when destination is another file system, however it
+     * is not guaranteed that those operations will succeed. If the modification operation fails, the methods throws
+     * IOException.
+     * </p>
+     *
+     * @param srcFile the file to be moved.
+     * @param destFile the destination file.
+     * @param preserveFileDate true if the file date of the "copy and delete" should be the same as the original when
+     *            destination is on another file system. Param is not used if destination is on same file system.
+     * @throws NullPointerException if any of the given {@code File}s are {@code null}.
+     * @throws FileExistsException if the destination file exists.
+     * @throws IOException if source or destination is invalid.
+     * @throws IOException if an error occurs or setting the last-modified time didn't succeeded.
+     * @since 1.4

Review comment:
       This is a new method for 2.9.0, please adjust the since tag.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org