public class SizeFileFilter extends Object implements FileFilter, Serializable
For example, to print all files and directories in the current directory whose size is greater than 1 MB:
FileSystemManager fsManager = VFS.getManager(); FileObject dir = fsManager.toFileObject(new File(".")); SizeFileFilter filter = new SizeFileFilter(1024 * 1024); FileObject[] files = dir.findFiles(new FileFilterSelector(filter)); for (int i = 0; i < files.length; i++) { System.out.println(files[i]); }
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(FileSelectInfo fileSelectInfo)
Checks to see if the size of the file is favorable.
|
String |
toString()
Provide a String representation of this file filter.
|
public SizeFileFilter(long size)
size
- the threshold size of the files - Must be non-negative.public SizeFileFilter(long size, boolean acceptLarger)
size
- the threshold size of the files - Must be non-negative.acceptLarger
- if true, files equal to or larger are accepted, otherwise
smaller ones (but not equal to)public boolean accept(FileSelectInfo fileSelectInfo) throws FileSystemException
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.
Non-existing files return always false (will never be accepted).
accept
in interface FileFilter
fileSelectInfo
- the File to checkFileSystemException
- Thrown for file system errors.Copyright © 2002–2020 The Apache Software Foundation. All rights reserved.