/** * Test if specified <code>File</code> is newer than the reference <code>File</code>. * * @param file the <code>File</code> of which the modification date must be compared * @param reference the <code>File</code> of which the modification date is used * @return <code>true</code> if the <code>File</code> exists and has been modified more * recently than the reference <code>File</code>. */ public static boolean isNewer(File file, File reference) { if (!reference.exists()) { throw new IllegalArgumentException("Reference file not found: " + reference); } return isNewer(file, reference.lastModified()); }
public static boolean isNewer(String file, long timeMillis) { return isNewer(file(file), timeMillis); }
/** * Uses {@link File#lastModified()} for reference. * * @see #isNewer(File, long) */ public static boolean isNewer(final File file, final File reference) { checkReferenceExists(reference); return isNewer(file, reference.lastModified()); }
/** * @see #isNewer(File, long) */ public static boolean isNewer(final String file, final long timeMillis) { return isNewer(file(file), timeMillis); }
public static boolean isNewer(String file, String reference) { return isNewer(file(file), file(reference)); }
/** * @see #isNewer(File, File) */ public static boolean isNewer(final String file, final String reference) { return isNewer(file(file), file(reference)); }
@Test void testFileManipulation() throws IOException { FileUtil.copy(new File(dataRoot, "sb.data"), new File(dataRoot, "sb1.data")); assertFalse(FileUtil.isNewer(new File(dataRoot, "sb.data"), new File(dataRoot, "sb1.data"))); assertFalse(FileUtil.isOlder(new File(dataRoot, "sb.data"), new File(dataRoot, "sb1.data"))); FileUtil.delete(new File(dataRoot, "sb1.data")); }
/** * @see #isNewer(File, long) */ public static boolean isNewer(final String file, final long timeMillis) { return isNewer(file(file), timeMillis); }
/** * Uses {@link File#lastModified()} for reference. * * @see #isNewer(File, long) */ public static boolean isNewer(final File file, final File reference) { checkReferenceExists(reference); return isNewer(file, reference.lastModified()); }
/** * @see #isNewer(File, File) */ public static boolean isNewer(final String file, final String reference) { return isNewer(file(file), file(reference)); }