You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ba...@apache.org on 2006/12/09 01:28:37 UTC

svn commit: r484861 - /jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java

Author: bayard
Date: Fri Dec  8 16:28:36 2006
New Revision: 484861

URL: http://svn.apache.org/viewvc?view=rev&rev=484861
Log:
Added a copyFileToDirectory(File, File, boolean) variant. No unit test as the lastModified checking part of the current tests is not being tested currently (it wasn't reliable). This is mentioned in #IO-104

Modified:
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java?view=diff&rev=484861&r1=484860&r2=484861
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java (original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java Fri Dec  8 16:28:36 2006
@@ -480,13 +480,35 @@
      * @see #copyFile(File, File, boolean)
      */
     public static void copyFileToDirectory(File srcFile, File destDir) throws IOException {
+        copyFileToDirectory(srcFile, destDir, true);
+    }
+
+    /**
+     * Copies a file to a directory optionally preserving the file date.
+     * <p>
+     * This method copies the contents of the specified source file
+     * to a file of the same name in the specified destination directory.
+     * The destination directory is created if it does not exist.
+     * If the destination file exists, then this method will overwrite it.
+     *
+     * @param srcFile  an existing file to copy, must not be null
+     * @param destDir  the directory to place the copy in, must not be null
+     * @param preserveFileDate  true if the file date of the copy
+     *  should be the same as the original
+     *
+     * @throws NullPointerException if source or destination is null
+     * @throws IOException if source or destination is invalid
+     * @throws IOException if an IO error occurs during copying
+     * @see #copyFile(File, File, boolean)
+     */
+    public static void copyFileToDirectory(File srcFile, File destDir, boolean preserveFileDate) throws IOException {
         if (destDir == null) {
             throw new NullPointerException("Destination must not be null");
         }
         if (destDir.exists() && destDir.isDirectory() == false) {
             throw new IllegalArgumentException("Destination '" + destDir + "' is not a directory");
         }
-        copyFile(srcFile, new File(destDir, srcFile.getName()), true);
+        copyFile(srcFile, new File(destDir, srcFile.getName()), preserveFileDate);
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org