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]);
}
| 构造器和说明 |
|---|
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.
|
public SizeFileFilter(long size)
size - the threshold size of the filesIllegalArgumentException - if the size is negativepublic SizeFileFilter(long size,
boolean acceptLarger)
size - the threshold size of the filesacceptLarger - if true, files equal to or larger are accepted,
otherwise smaller ones (but not equal to)IllegalArgumentException - if the size is negativepublic boolean accept(File file)
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.
accept 在接口中 FileFilteraccept 在接口中 IOFileFilteraccept 在类中 AbstractFileFilterfile - the File to checkpublic String toString()
toString 在类中 AbstractFileFilter