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]);
}
| Modifier and Type | Field and Description |
|---|---|
| private boolean | acceptOlder
Whether the files accepted will be older or newer. |
| private long | cutoff
The cutoff time threshold. |
| Access | Constructor and Description |
|---|---|
| public | AgeFileFilter(long
the threshold age of the files cutoff)Constructs a new age file filter for files equal to or older than a certain cutoff |
| public | AgeFileFilter(long
the threshold age of the files cutoff, boolean if true, older files (at or before the cutoff)
are accepted, else newer ones (after the cutoff). acceptOlder)Constructs a new age file filter for files on any one side of a certain cutoff. |
| public | AgeFileFilter(Date
the threshold age of the files cutoffDate)Constructs a new age file filter for files older than (at or before) a certain cutoff date. |
| public | AgeFileFilter(Date
the threshold age of the files cutoffDate, boolean if true, older files (at or before the cutoff)
are accepted, else newer ones (after the cutoff). acceptOlder)Constructs a new age file filter for files on any one side of a certain cutoff date. |
| public | AgeFileFilter(File
the file whose last modification
time is usesd as the threshold age of the files 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). |
| public | AgeFileFilter(File
the file whose last modification
time is usesd as the threshold age of the files cutoffReference, boolean if true, older files (at or before the cutoff)
are accepted, else newer ones (after the cutoff). 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). |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if the filename matchesthe File to check file)Overrides org. Implements org. |
| acceptOlder | back to summary |
|---|---|
| private boolean acceptOlder Whether the files accepted will be older or newer. | |
| cutoff | back to summary |
|---|---|
| private long cutoff The cutoff time threshold. | |
| AgeFileFilter | back to summary |
|---|---|
| public AgeFileFilter(long cutoff) Constructs a new age file filter for files equal to or older than a certain cutoff
| |
| AgeFileFilter | back to summary |
|---|---|
| public AgeFileFilter(long cutoff, boolean acceptOlder) Constructs a new age file filter for files on any one side of a certain cutoff.
| |
| AgeFileFilter | back to summary |
|---|---|
| public AgeFileFilter(Date cutoffDate) Constructs a new age file filter for files older than (at or before) a certain cutoff date.
| |
| AgeFileFilter | back to summary |
|---|---|
| public AgeFileFilter(Date cutoffDate, boolean acceptOlder) Constructs a new age file filter for files on any one side of a certain cutoff date.
| |
| AgeFileFilter | back to summary |
|---|---|
| public 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 | back to summary |
|---|---|
| public 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).
| |
| accept | back to summary |
|---|---|
| public boolean accept(File file) Overrides org. Implements org. Checks to see if the last modification of the file matches cutoff favorably. 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.
| |