Package org.apache.commons.vfs2.filter
Class PrefixFileFilter
java.lang.Object
org.apache.commons.vfs2.filter.PrefixFileFilter
- All Implemented Interfaces:
Serializable
,FileFilter
Filters file names for a certain prefix.
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]); }
- Since:
- 2.4
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final IOCase
Whether the comparison is case sensitive.The file name prefixes to search for.private static final long
-
Constructor Summary
ConstructorsConstructorDescriptionPrefixFileFilter
(String... prefixes) Constructs a new Prefix file filter for any of an array of prefixes.PrefixFileFilter
(List<String> prefixes) Constructs a new Prefix file filter for a list of prefixes.PrefixFileFilter
(IOCase caseSensitivity, String... prefixes) Constructs a new Prefix file filter for any of an array of prefixes specifying case-sensitivity.PrefixFileFilter
(IOCase caseSensitivity, List<String> prefixes) Constructs a new Prefix file filter for a list of prefixes specifying case-sensitivity. -
Method Summary
Modifier and TypeMethodDescriptionboolean
accept
(FileSelectInfo fileSelectInfo) Checks to see if the file name starts with the prefix.toString()
Provide a String representation of this file filter.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
caseSensitivity
Whether the comparison is case sensitive. -
prefixes
The file name prefixes to search for.
-
-
Constructor Details
-
PrefixFileFilter
Constructs a new Prefix file filter for a list of prefixes.- Parameters:
prefixes
- the prefixes to allow, must not be null
-
PrefixFileFilter
Constructs a new Prefix file filter for a list of prefixes specifying case-sensitivity.- Parameters:
caseSensitivity
- how to handle case sensitivity, null means case-sensitiveprefixes
- the prefixes to allow, must not be null
-
PrefixFileFilter
Constructs a new Prefix file filter for any of an array of prefixes.The array is not cloned, so could be changed after constructing the instance. This would be inadvisable however.
- Parameters:
prefixes
- the prefixes to allow, must not be null
-
PrefixFileFilter
Constructs a new Prefix file filter for any of an array of prefixes specifying case-sensitivity.- Parameters:
caseSensitivity
- how to handle case sensitivity, null means case-sensitiveprefixes
- the prefixes to allow, must not be null
-
-
Method Details
-
accept
Checks to see if the file name starts with the prefix.- Specified by:
accept
in interfaceFileFilter
- Parameters:
fileSelectInfo
- the File to check- Returns:
- true if the file name starts with one of our prefixes
-
toString
Provide a String representation of this file filter.
-