@@ -1164,7 +1164,7 @@ private static void doCopyFileUsingNewIO( File source, File destination )
1164
1164
public static boolean copyFileIfModified ( final File source , final File destination )
1165
1165
throws IOException
1166
1166
{
1167
- if ( destination . lastModified () < source . lastModified ( ) )
1167
+ if ( isSourceNewerThanDestination ( source , destination ) )
1168
1168
{
1169
1169
copyFile ( source , destination );
1170
1170
@@ -2289,7 +2289,7 @@ public static File createTempFile( String prefix, String suffix, File parentDir
2289
2289
}
2290
2290
2291
2291
/**
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>
2293
2293
*
2294
2294
* @param from the file to copy
2295
2295
* @param to the destination file
@@ -2309,15 +2309,13 @@ public static abstract class FilterWrapper
2309
2309
}
2310
2310
2311
2311
/**
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>
2314
2313
*
2315
2314
* @param from the file to copy
2316
2315
* @param to the destination file
2317
2316
* @param encoding the file output encoding (only if wrappers is not empty)
2318
2317
* @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()}
2321
2319
* @throws IOException if an IO error occurs during copying or filtering
2322
2320
* @since 1.5.2
2323
2321
*/
@@ -2367,13 +2365,17 @@ public static void copyFile( File from, File to, String encoding, FilterWrapper[
2367
2365
}
2368
2366
else
2369
2367
{
2370
- if ( to . lastModified () < from . lastModified ( ) || overwrite )
2368
+ if ( isSourceNewerThanDestination ( from , to ) || overwrite )
2371
2369
{
2372
2370
copyFile ( from , to );
2373
2371
}
2374
2372
}
2375
2373
}
2376
2374
2375
+ private static boolean isSourceNewerThanDestination ( File source , File destination ) {
2376
+ return ( destination .lastModified () == 0L && source .lastModified () == 0L ) || destination .lastModified () < source .lastModified ();
2377
+ }
2378
+
2377
2379
/**
2378
2380
* Note: the file content is read with platform encoding
2379
2381
*
0 commit comments