@@ -1164,7 +1164,7 @@ private static void doCopyFileUsingNewIO( File source, File destination )
11641164 public static boolean copyFileIfModified ( final File source , final File destination )
11651165 throws IOException
11661166 {
1167- if ( destination . lastModified () < source . lastModified ( ) )
1167+ if ( isSourceNewerThanDestination ( source , destination ) )
11681168 {
11691169 copyFile ( source , destination );
11701170
@@ -2289,7 +2289,7 @@ public static File createTempFile( String prefix, String suffix, File parentDir
22892289 }
22902290
22912291 /**
2292- * <b>If wrappers is null or empty, the file will be copy only if to.lastModified() < from.lastModified()</b>
2292+ * <b>If wrappers is null or empty, the file will be copy only if {@code to.lastModified() < from.lastModified()} </b>
22932293 *
22942294 * @param from the file to copy
22952295 * @param to the destination file
@@ -2309,15 +2309,13 @@ public static abstract class FilterWrapper
23092309 }
23102310
23112311 /**
2312- * <b>If wrappers is null or empty, the file will be copy only if to.lastModified() < from.lastModified() or if
2313- * overwrite is true</b>
2312+ * <b>If wrappers is null or empty, the file will be copy only if {@code to.lastModified() < from.lastModified()}, if overwrite is true</b>
23142313 *
23152314 * @param from the file to copy
23162315 * @param to the destination file
23172316 * @param encoding the file output encoding (only if wrappers is not empty)
23182317 * @param wrappers array of {@link FilterWrapper}
2319- * @param overwrite if true and f wrappers is null or empty, the file will be copy even if to.lastModified() <
2320- * from.lastModified()
2318+ * @param overwrite if true and wrappers is null or empty, the file will be copied even if {@code to.lastModified() < from.lastModified()}
23212319 * @throws IOException if an IO error occurs during copying or filtering
23222320 * @since 1.5.2
23232321 */
@@ -2367,13 +2365,17 @@ public static void copyFile( File from, File to, String encoding, FilterWrapper[
23672365 }
23682366 else
23692367 {
2370- if ( to . lastModified () < from . lastModified ( ) || overwrite )
2368+ if ( isSourceNewerThanDestination ( from , to ) || overwrite )
23712369 {
23722370 copyFile ( from , to );
23732371 }
23742372 }
23752373 }
23762374
2375+ private static boolean isSourceNewerThanDestination ( File source , File destination ) {
2376+ return ( destination .lastModified () == 0L && source .lastModified () == 0L ) || destination .lastModified () < source .lastModified ();
2377+ }
2378+
23772379 /**
23782380 * Note: the file content is read with platform encoding
23792381 *
0 commit comments