public class PrefixFileFilter extends java.lang.Object implements FileFilter, java.io.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]); }
Modifier and Type | Field and Description |
---|---|
private IOCase |
caseSensitivity
Whether the comparison is case sensitive.
|
private java.util.List<java.lang.String> |
prefixes
The file name prefixes to search for.
|
private static long |
serialVersionUID |
Constructor and Description |
---|
PrefixFileFilter(IOCase caseSensitivity,
java.util.List<java.lang.String> prefixes)
Constructs a new Prefix file filter for a list of prefixes specifying
case-sensitivity.
|
PrefixFileFilter(IOCase caseSensitivity,
java.lang.String... prefixes)
Constructs a new Prefix file filter for any of an array of prefixes
specifying case-sensitivity.
|
PrefixFileFilter(java.util.List<java.lang.String> prefixes)
Constructs a new Prefix file filter for a list of prefixes.
|
PrefixFileFilter(java.lang.String... prefixes)
Constructs a new Prefix file filter for any of an array of prefixes.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(FileSelectInfo fileInfo)
Checks to see if the file name starts with the prefix.
|
java.lang.String |
toString()
Provide a String representation of this file filter.
|
private static final long serialVersionUID
private final IOCase caseSensitivity
private final java.util.List<java.lang.String> prefixes
public PrefixFileFilter(java.util.List<java.lang.String> prefixes)
prefixes
- the prefixes to allow, must not be nullpublic PrefixFileFilter(IOCase caseSensitivity, java.util.List<java.lang.String> prefixes)
caseSensitivity
- how to handle case sensitivity, null means
case-sensitiveprefixes
- the prefixes to allow, must not be nullpublic PrefixFileFilter(java.lang.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, java.lang.String... prefixes)
prefixes
- the prefixes to allow, must not be nullcaseSensitivity
- how to handle case sensitivity, null means
case-sensitivepublic boolean accept(FileSelectInfo fileInfo)
accept
in interface FileFilter
fileInfo
- the File to checkpublic java.lang.String toString()
toString
in class java.lang.Object