Contents
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
- Author:
- This code was originally ported from Apache Commons IO File Filter
- See Also:
-
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 suffixes 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.
-
Constructor Details
-
SuffixFileFilter
Constructs a new Suffix file filter for a list of suffixes specifying case-sensitivity.- Parameters:
caseSensitivity
- how to handle case sensitivity, null means case-sensitivesuffixes
- the suffixes to allow, must not be null
-
SuffixFileFilter
Constructs a new Suffix file filter for an array of suffixes specifying case-sensitivity.- Parameters:
caseSensitivity
- how to handle case sensitivity, null means case-sensitivesuffixes
- the suffixes to allow, must not be null
-
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 an array of suffixes.- Parameters:
suffixes
- the suffixes to allow, must not be null
-
-
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
-