/** * Tests if the specified <code>File</code> is older than the specified * <code>Date</code>. * * @param file the <code>File</code> of which the modification date * must be compared, must not be {@code null} * @param date the date reference, must not be {@code null} * @return true if the <code>File</code> exists and has been modified * before the given <code>Date</code>. * @throws IllegalArgumentException if the file is {@code null} * @throws IllegalArgumentException if the date is {@code null} */ public static boolean isFileOlder(final File file, final Date date) { if (date == null) { throw new IllegalArgumentException("No specified date"); } return isFileOlder(file, date.getTime()); }
/** * Tests if the specified <code>File</code> is older than the reference * <code>File</code>. * * @param file the <code>File</code> of which the modification date must * be compared, must not be {@code null} * @param reference the <code>File</code> of which the modification date * is used, must not be {@code null} * @return true if the <code>File</code> exists and has been modified before * the reference <code>File</code> * @throws IllegalArgumentException if the file is {@code null} * @throws IllegalArgumentException if the reference file is {@code null} or doesn't exist */ public static boolean isFileOlder(final File file, final File reference) { if (reference == null) { throw new IllegalArgumentException("No specified reference file"); } if (!reference.exists()) { throw new IllegalArgumentException("The reference file '" + reference + "' doesn't exist"); } return isFileOlder(file, reference.lastModified()); }
/** * Tests if the specified <code>File</code> is older than the specified * <code>Date</code>. * * @param file the <code>File</code> of which the modification date * must be compared, must not be <code>null</code> * @param date the date reference, must not be <code>null</code> * @return true if the <code>File</code> exists and has been modified * before the given <code>Date</code>. * @throws IllegalArgumentException if the file is <code>null</code> * @throws IllegalArgumentException if the date is <code>null</code> */ public static boolean isFileOlder(File file, Date date) { if (date == null) { throw new IllegalArgumentException("No specified date"); } return isFileOlder(file, date.getTime()); }
/** * Tests if the specified <code>File</code> is older than the reference * <code>File</code>. * * @param file the <code>File</code> of which the modification date must * be compared, must not be <code>null</code> * @param reference the <code>File</code> of which the modification date * is used, must not be <code>null</code> * @return true if the <code>File</code> exists and has been modified before * the reference <code>File</code> * @throws IllegalArgumentException if the file is <code>null</code> * @throws IllegalArgumentException if the reference file is <code>null</code> or doesn't exist */ public static boolean isFileOlder(File file, File reference) { if (reference == null) { throw new IllegalArgumentException("No specified reference file"); } if (!reference.exists()) { throw new IllegalArgumentException("The reference file '" + file + "' doesn't exist"); } return isFileOlder(file, reference.lastModified()); }
assertTrue("Old File - Older - File", FileUtils.isFileOlder(oldFile, reference)); assertTrue("Old File - Older - Date", FileUtils.isFileOlder(oldFile, date)); assertTrue("Old File - Older - Mili", FileUtils.isFileOlder(oldFile, now)); assertFalse("New File - Older - File", FileUtils.isFileOlder(newFile, reference)); assertFalse("New File - Older - Date", FileUtils.isFileOlder(newFile, date)); assertFalse("New File - Older - Mili", FileUtils.isFileOlder(newFile, now)); assertFalse("Invalid - Older - File", FileUtils.isFileOlder(invalidFile, reference)); try { FileUtils.isFileOlder(newFile, invalidFile); fail("Should have cause IllegalArgumentException"); } catch (final IllegalArgumentException iae) { FileUtils.isFileOlder(null, now); fail("Older Null, expected IllegalArgumentExcepion"); } catch (final IllegalArgumentException ignore) { FileUtils.isFileOlder(oldFile, (File) null); fail("Older Null reference, expected IllegalArgumentExcepion"); } catch (final IllegalArgumentException ignore) { FileUtils.isFileOlder(oldFile, invalidFile); fail("Older invalid reference, expected IllegalArgumentExcepion"); } catch (final IllegalArgumentException ignore) { FileUtils.isFileOlder(oldFile, (Date) null); fail("Older Null date, expected IllegalArgumentExcepion"); } catch (final IllegalArgumentException ignore) {
if (!inputFile.exists() | (theCacheFile && FileUtils.isFileOlder(inputFile, cacheExpiryDate))) {
@Override public boolean apply(@Nullable File input) { if (!input.isDirectory() && ( (maxLastModifiedTime <= 0) || FileUtils.isFileOlder(input, maxLastModifiedTime))) { return true; } return false; } }).iterator();
@Override public boolean apply(@Nullable File input) { if (!input.isDirectory() && ( (maxLastModifiedTime <= 0) || FileUtils.isFileOlder(input, maxLastModifiedTime))) { return true; } return false; } }).iterator();
@Override public boolean apply(@Nullable File input) { if (!input.isDirectory() && ( (maxLastModifiedTime <= 0) || FileUtils.isFileOlder(input, maxLastModifiedTime))) { return true; } return false; } }).iterator();
/** * Tests if the specified <code>File</code> is older than the specified * <code>Date</code>. * * @param file the <code>File</code> of which the modification date * must be compared, must not be {@code null} * @param date the date reference, must not be {@code null} * @return true if the <code>File</code> exists and has been modified * before the given <code>Date</code>. * @throws IllegalArgumentException if the file is {@code null} * @throws IllegalArgumentException if the date is {@code null} */ public static boolean isFileOlder(final File file, final Date date) { if (date == null) { throw new IllegalArgumentException("No specified date"); } return isFileOlder(file, date.getTime()); }
/** * Tests if the specified <code>File</code> is older than the specified * <code>Date</code>. * * @param file the <code>File</code> of which the modification date * must be compared, must not be <code>null</code> * @param date the date reference, must not be <code>null</code> * @return true if the <code>File</code> exists and has been modified * before the given <code>Date</code>. * @throws IllegalArgumentException if the file is <code>null</code> * @throws IllegalArgumentException if the date is <code>null</code> */ public static boolean isFileOlder(File file, Date date) { if (date == null) { throw new IllegalArgumentException("No specified date"); } return isFileOlder(file, date.getTime()); }
/** * Tests if the specified <code>File</code> is older than the specified * <code>Date</code>. * * @param file the <code>File</code> of which the modification date * must be compared, must not be {@code null} * @param date the date reference, must not be {@code null} * @return true if the <code>File</code> exists and has been modified * before the given <code>Date</code>. * @throws IllegalArgumentException if the file is {@code null} * @throws IllegalArgumentException if the date is {@code null} */ public static boolean isFileOlder(final File file, final Date date) { if (date == null) { throw new IllegalArgumentException("No specified date"); } return isFileOlder(file, date.getTime()); }
/** * Tests if the specified <code>File</code> is older than the specified * <code>Date</code>. * * @param file the <code>File</code> of which the modification date * must be compared, must not be <code>null</code> * @param date the date reference, must not be <code>null</code> * @return true if the <code>File</code> exists and has been modified * before the given <code>Date</code>. * @throws IllegalArgumentException if the file is <code>null</code> * @throws IllegalArgumentException if the date is <code>null</code> */ public static boolean isFileOlder(File file, Date date) { if (date == null) { throw new IllegalArgumentException("No specified date"); } return isFileOlder(file, date.getTime()); }
/** * Tests if the specified <code>File</code> is older than the specified * <code>Date</code>. * * @param file the <code>File</code> of which the modification date * must be compared, must not be {@code null} * @param date the date reference, must not be {@code null} * @return true if the <code>File</code> exists and has been modified * before the given <code>Date</code>. * @throws IllegalArgumentException if the file is {@code null} * @throws IllegalArgumentException if the date is {@code null} */ public static boolean isFileOlder(File file, Date date) { if (date == null) { throw new IllegalArgumentException("No specified date"); } return isFileOlder(file, date.getTime()); }
/** * Tests if the specified <code>File</code> is older than the specified * <code>Date</code>. * * @param file the <code>File</code> of which the modification date * must be compared, must not be <code>null</code> * @param date the date reference, must not be <code>null</code> * @return true if the <code>File</code> exists and has been modified * before the given <code>Date</code>. * @throws IllegalArgumentException if the file is <code>null</code> * @throws IllegalArgumentException if the date is <code>null</code> */ public static boolean isFileOlder(File file, Date date) { if (date == null) { throw new IllegalArgumentException("No specified date"); } return isFileOlder(file, date.getTime()); }
@Override public boolean accept(File file) { long timeMillis = System.currentTimeMillis() - cutoff; if(after) { return FileUtils.isFileNewer(file, timeMillis); } else { return FileUtils.isFileOlder(file, timeMillis); } }
/** * Tests if the specified <code>File</code> is older than the reference * <code>File</code>. * * @param file the <code>File</code> of which the modification date must * be compared, must not be <code>null</code> * @param reference the <code>File</code> of which the modification date * is used, must not be <code>null</code> * @return true if the <code>File</code> exists and has been modified before * the reference <code>File</code> * @throws IllegalArgumentException if the file is <code>null</code> * @throws IllegalArgumentException if the reference file is <code>null</code> or doesn't exist */ public static boolean isFileOlder(File file, File reference) { if (reference == null) { throw new IllegalArgumentException("No specified reference file"); } if (!reference.exists()) { throw new IllegalArgumentException("The reference file '" + file + "' doesn't exist"); } return isFileOlder(file, reference.lastModified()); }
@Override public long countDeleteChunks(List<String> chunkIds, long maxLastModifiedTime) throws Exception { int count = 0; for (String chunkId : chunkIds) { byte[] digest = StringUtils.convertHexToBytes(chunkId); File f = getFile(digest, false); if (!f.exists()) { File old = getFile(digest, true); f.getParentFile().mkdir(); old.renameTo(f); f = getFile(digest, false); } if ((maxLastModifiedTime <= 0) || FileUtils.isFileOlder(f, maxLastModifiedTime)) { f.delete(); count++; } } return count; }
@Override public long countDeleteChunks(List<String> chunkIds, long maxLastModifiedTime) throws Exception { int count = 0; for (String chunkId : chunkIds) { byte[] digest = StringUtils.convertHexToBytes(chunkId); File f = getFile(digest, false); if (!f.exists()) { File old = getFile(digest, true); f.getParentFile().mkdir(); old.renameTo(f); f = getFile(digest, false); } if ((maxLastModifiedTime <= 0) || FileUtils.isFileOlder(f, maxLastModifiedTime)) { f.delete(); count++; } } return count; }
@Override public long countDeleteChunks(List<String> chunkIds, long maxLastModifiedTime) throws Exception { int count = 0; for (String chunkId : chunkIds) { byte[] digest = StringUtils.convertHexToBytes(chunkId); File f = getFile(digest, false); if (!f.exists()) { File old = getFile(digest, true); f.getParentFile().mkdir(); old.renameTo(f); f = getFile(digest, false); } if ((maxLastModifiedTime <= 0) || FileUtils.isFileOlder(f, maxLastModifiedTime)) { f.delete(); count++; } } return count; }