本文整理了Java中org.apache.commons.io.FileUtils.isFileOlder()
方法的一些代码示例,展示了FileUtils.isFileOlder()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.isFileOlder()
方法的具体详情如下:
包路径:org.apache.commons.io.FileUtils
类名称:FileUtils
方法名:isFileOlder
[英]Tests if the specified File
is older than the specified time reference.
[中]测试指定的File
是否早于指定的时间引用。
代码示例来源:origin: commons-io/commons-io
/**
* 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());
}
代码示例来源:origin: commons-io/commons-io
/**
* 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());
}
代码示例来源:origin: org.apache.commons/commons-io
/**
* 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());
}
代码示例来源:origin: org.apache.commons/commons-io
/**
* 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());
}
代码示例来源:origin: commons-io/commons-io
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) {
代码示例来源:origin: jamesagnew/hapi-fhir
if (!inputFile.exists() | (theCacheFile && FileUtils.isFileOlder(inputFile, cacheExpiryDate))) {
代码示例来源:origin: apache/jackrabbit-oak
@Override
public boolean apply(@Nullable File input) {
if (!input.isDirectory() && (
(maxLastModifiedTime <= 0)
|| FileUtils.isFileOlder(input, maxLastModifiedTime))) {
return true;
}
return false;
}
}).iterator();
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
@Override
public boolean apply(@Nullable File input) {
if (!input.isDirectory() && (
(maxLastModifiedTime <= 0)
|| FileUtils.isFileOlder(input, maxLastModifiedTime))) {
return true;
}
return false;
}
}).iterator();
代码示例来源:origin: org.apache.jackrabbit/oak-blob
@Override
public boolean apply(@Nullable File input) {
if (!input.isDirectory() && (
(maxLastModifiedTime <= 0)
|| FileUtils.isFileOlder(input, maxLastModifiedTime))) {
return true;
}
return false;
}
}).iterator();
代码示例来源:origin: io.github.stephenc.docker/docker-client-shaded
/**
* 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());
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-io
/**
* 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());
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
/**
* 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());
}
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.io
/**
* 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());
}
代码示例来源:origin: org.onosproject/onlab-thirdparty
/**
* 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());
}
代码示例来源:origin: Nextdoor/bender
/**
* 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());
}
代码示例来源:origin: didfet/logstash-forwarder-java
@Override
public boolean accept(File file) {
long timeMillis = System.currentTimeMillis() - cutoff;
if(after) {
return FileUtils.isFileNewer(file, timeMillis);
} else {
return FileUtils.isFileOlder(file, timeMillis);
}
}
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.io
/**
* 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());
}
代码示例来源:origin: apache/jackrabbit-oak
@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;
}
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
@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;
}
代码示例来源:origin: org.apache.jackrabbit/oak-blob
@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;
}
内容来源于网络,如有侵权,请联系作者删除!