public class PrefixFileFilter extends Object implements FileFilter, Serializable
For example, to print all files and directories in the current directory
whose name starts with a .
:
FileSystemManager fsManager = VFS.getManager(); FileObject dir = fsManager.toFileObject(new File(".")); FileObject[] files = dir.findFiles(new FileFilterSelector(new PrefixFileFilter("."))); for (int i = 0; i < files.length; i++) { System.out.println(files[i]); }
Constructor and Description |
---|
PrefixFileFilter(IOCase caseSensitivity,
List<String> prefixes)
Constructs a new Prefix file filter for a list of prefixes specifying
case-sensitivity.
|
PrefixFileFilter(IOCase caseSensitivity,
String... prefixes)
Constructs a new Prefix file filter for any of an array of prefixes
specifying case-sensitivity.
|
PrefixFileFilter(List<String> prefixes)
Constructs a new Prefix file filter for a list of prefixes.
|
PrefixFileFilter(String... prefixes)
Constructs a new Prefix file filter for any of an array of prefixes.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(FileSelectInfo fileSelectInfo)
Checks to see if the file name starts with the prefix.
|
String |
toString()
Provide a String representation of this file filter.
|
public PrefixFileFilter(List<String> prefixes)
prefixes
- the prefixes to allow, must not be nullpublic PrefixFileFilter(IOCase caseSensitivity, List<String> prefixes)
caseSensitivity
- how to handle case sensitivity, null means
case-sensitiveprefixes
- the prefixes to allow, must not be nullpublic PrefixFileFilter(String... prefixes)
The array is not cloned, so could be changed after constructing the instance. This would be inadvisable however.
prefixes
- the prefixes to allow, must not be nullpublic PrefixFileFilter(IOCase caseSensitivity, String... prefixes)
prefixes
- the prefixes to allow, must not be nullcaseSensitivity
- how to handle case sensitivity, null means
case-sensitivepublic boolean accept(FileSelectInfo fileSelectInfo)
accept
in interface FileFilter
fileSelectInfo
- the File to checkCopyright © 2002–2020 The Apache Software Foundation. All rights reserved.