| java.lang.Object org.apache.commons.io.filefilter.AbstractFileFilter org.apache.commons.io.filefilter.SizeFileFilter
SizeFileFilter | public class SizeFileFilter extends AbstractFileFilter (Code) | | Filters files based on size, can filter either smaller files or
files equal to or larger than 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]);
}
author: Rahul Akolkar version: $Id: SizeFileFilter.java 463570 2006-10-13 06:14:41Z niallp $ since: Commons IO 1.2 |
Constructor Summary | |
public | SizeFileFilter(long size) Constructs a new size file filter for files equal to or
larger than a certain size. | public | SizeFileFilter(long size, boolean acceptLarger) Constructs a new size file filter for files based on a certain size
threshold. |
Method Summary | |
public boolean | accept(File file) Checks to see if the size of the file is favorable. |
SizeFileFilter | public SizeFileFilter(long size)(Code) | | Constructs a new size file filter for files equal to or
larger than a certain size.
Parameters: size - the threshold size of the files throws: IllegalArgumentException - if the size is negative |
SizeFileFilter | public SizeFileFilter(long size, boolean acceptLarger)(Code) | | Constructs a new size file filter for files based on a certain size
threshold.
Parameters: size - the threshold size of the files Parameters: acceptLarger - if true, files equal to or larger are accepted,otherwise smaller ones (but not equal to) throws: IllegalArgumentException - if the size is negative |
accept | public boolean accept(File file)(Code) | | Checks to see if the size of the file is favorable.
If size equals threshold and smaller files are required,
file IS NOT selected.
If size equals threshold and larger files are required,
file IS selected.
Parameters: file - the File to check true if the filename matches |
|
|