org.apache.commons.io.filefilter
public class AgeFileFilter extends AbstractFileFilter implements Serializable
For example, to print all files and directories in the current directory older than one day:
File dir = new File("."); // We are interested in files older than one day long cutoff = System.currentTimeMillis() - (24 * 60 * 60 * 1000); String[] files = dir.list( new AgeFileFilter(cutoff) ); for ( int i = 0; i < files.length; i++ ) { System.out.println(files[i]); }
Since: Commons IO 1.2
Version: $Id: AgeFileFilter.java 606381 2007-12-22 02:03:16Z ggregory $
Field Summary | |
---|---|
boolean | acceptOlder Whether the files accepted will be older or newer. |
long | cutoff The cutoff time threshold. |
Constructor Summary | |
---|---|
AgeFileFilter(long cutoff)
Constructs a new age file filter for files equal to or older than
a certain cutoff
| |
AgeFileFilter(long cutoff, boolean acceptOlder)
Constructs a new age file filter for files on any one side
of a certain cutoff.
| |
AgeFileFilter(Date cutoffDate)
Constructs a new age file filter for files older than (at or before)
a certain cutoff date.
| |
AgeFileFilter(Date cutoffDate, boolean acceptOlder)
Constructs a new age file filter for files on any one side
of a certain cutoff date.
| |
AgeFileFilter(File cutoffReference)
Constructs a new age file filter for files older than (at or before)
a certain File (whose last modification time will be used as reference).
| |
AgeFileFilter(File cutoffReference, boolean acceptOlder)
Constructs a new age file filter for files on any one side
of a certain File (whose last modification time will be used as
reference).
|
Method Summary | |
---|---|
boolean | accept(File file)
Checks to see if the last modification of the file matches cutoff
favorably.
|
String | toString()
Provide a String representaion of this file filter.
|
Parameters: cutoff the threshold age of the files
Parameters: cutoff the threshold age of the files acceptOlder if true, older files (at or before the cutoff) are accepted, else newer ones (after the cutoff).
Parameters: cutoffDate the threshold age of the files
Parameters: cutoffDate the threshold age of the files acceptOlder if true, older files (at or before the cutoff) are accepted, else newer ones (after the cutoff).
Parameters: cutoffReference the file whose last modification time is usesd as the threshold age of the files
Parameters: cutoffReference the file whose last modification time is usesd as the threshold age of the files acceptOlder if true, older files (at or before the cutoff) are accepted, else newer ones (after the cutoff).
If last modification time equals cutoff and newer files are required, file IS NOT selected. If last modification time equals cutoff and older files are required, file IS selected.
Parameters: file the File to check
Returns: true if the filename matches
Returns: a String representaion