org.apache.commons.io.filefilter
public class SizeFileFilter extends AbstractFileFilter implements Serializable
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]); }
Since: Commons IO 1.2
Version: $Id: SizeFileFilter.java 591058 2007-11-01 15:47:05Z niallp $
Field Summary | |
---|---|
boolean | acceptLarger Whether the files accepted will be larger or smaller. |
long | size The size threshold. |
Constructor Summary | |
---|---|
SizeFileFilter(long size)
Constructs a new size file filter for files equal to or
larger than a certain size.
| |
SizeFileFilter(long size, boolean acceptLarger)
Constructs a new size file filter for files based on a certain size
threshold.
|
Method Summary | |
---|---|
boolean | accept(File file)
Checks to see if the size of the file is favorable.
|
String | toString()
Provide a String representaion of this file filter.
|
Parameters: size the threshold size of the files
Throws: IllegalArgumentException if the size is negative
Parameters: size the threshold size of the files acceptLarger if true, files equal to or larger are accepted, otherwise smaller ones (but not equal to)
Throws: IllegalArgumentException if the size is negative
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
Returns: true if the filename matches
Returns: a String representaion