Package org.apache.commons.vfs2.filter
Class SuffixFileFilter
java.lang.Object
org.apache.commons.vfs2.filter.SuffixFileFilter
- All Implemented Interfaces:
Serializable
,FileFilter
Filters files based on the suffix (what the file name ends with). This is used
in retrieving all the files of a particular type.
For example, to retrieve and print all *.java
files in the
current directory:
FileSystemManager fsManager = VFS.getManager(); FileObject dir = fsManager.toFileObject(new File(".")); FileObject[] files = dir.findFiles(new FileFilterSelector(new SuffixFileFilter(".java"))); for (int i = 0; i < files.length; i++) { System.out.println(files[i]); }
- Since:
- 2.4
- See Also:
-
- "http://commons.apache.org/proper/commons-io/"
- Serialized Form
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final IOCase
Whether the comparison is case sensitive.private static final long
The file name suffixes to search for. -
Constructor Summary
ConstructorsConstructorDescriptionSuffixFileFilter
(String... suffixes) Constructs a new Suffix file filter for an array of suffixes.SuffixFileFilter
(List<String> suffixes) Constructs a new Suffix file filter for a list of suffixes.SuffixFileFilter
(IOCase caseSensitivity, String... suffixes) Constructs a new Suffix file filter for an array of suffixs specifying case-sensitivity.SuffixFileFilter
(IOCase caseSensitivity, List<String> suffixes) Constructs a new Suffix file filter for a list of suffixes specifying case-sensitivity. -
Method Summary
Modifier and TypeMethodDescriptionboolean
accept
(FileSelectInfo fileSelectInfo) Checks to see if the file name ends with the suffix.toString()
Provides a String representation of this file filter.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
caseSensitivity
Whether the comparison is case sensitive. -
suffixes
The file name suffixes to search for.
-
-
Constructor Details
-
SuffixFileFilter
Constructs a new Suffix file filter for a list of suffixes.- Parameters:
suffixes
- the suffixes to allow, must not be null
-
SuffixFileFilter
Constructs a new Suffix file filter for a list of suffixes specifying case-sensitivity.- Parameters:
suffixes
- the suffixes to allow, must not be nullcaseSensitivity
- how to handle case sensitivity, null means case-sensitive
-
SuffixFileFilter
Constructs a new Suffix file filter for an array of suffixes.- Parameters:
suffixes
- the suffixes to allow, must not be null
-
SuffixFileFilter
Constructs a new Suffix file filter for an array of suffixs specifying case-sensitivity.- Parameters:
suffixes
- the suffixes to allow, must not be nullcaseSensitivity
- how to handle case sensitivity, null means case-sensitive
-
-
Method Details
-
accept
Checks to see if the file name ends with the suffix.- Specified by:
accept
in interfaceFileFilter
- Parameters:
fileSelectInfo
- the File to check- Returns:
- true if the file name ends with one of our suffixes
-
toString
Provides a String representation of this file filter.
-