org.apache.commons.io.filefilter
Class SizeFileFilter
- FileFilter, FilenameFilter, IOFileFilter
public class SizeFileFilter
Filters files based on size, can filter either larger or smaller files
as compared to a given threshold.
For example, to print all files and directories in the
current directory whose size is greater than 1 MB:
File dir = new File(".");
String[] files = dir.list( new SizeFileFilter(1024 * 1024) );
for ( int i = 0; i < files.length; i++ ) {
System.out.println(files[i]);
}
$Id: SizeFileFilter.java 360504 2006-01-01 17:49:18Z scolebourne $private boolean | acceptLarger - Whether the files accepted will be larger or smaller.
|
private long | size - The size threshold.
|
SizeFileFilter(long size) - Constructs a new size file filter for files larger than a certain size.
|
SizeFileFilter(long size, boolean acceptLarger) - Constructs a new size file filter for files based on a certain size
threshold.
|
boolean | accept(File file) - Checks to see if the size of the file is favorable.
|
acceptLarger
private boolean acceptLarger
Whether the files accepted will be larger or smaller.
size
private long size
The size threshold.
SizeFileFilter
public SizeFileFilter(long size)
Constructs a new size file filter for files larger than a certain size.
size
- the threshold size of the files
SizeFileFilter
public SizeFileFilter(long size,
boolean acceptLarger)
Constructs a new size file filter for files based on a certain size
threshold.
size
- the threshold size of the filesacceptLarger
- if true, larger files are accepted, else smaller ones
accept
public boolean accept(File file)
Checks to see if the size of the file is favorable.
If size equals threshold, file is not selected.
- accept in interface IOFileFilter
- accept in interface AbstractFileFilter
- true if the filename matches