Package org.apache.commons.vfs2.filter
Class SuffixFileFilter
- java.lang.Object
-
- org.apache.commons.vfs2.filter.SuffixFileFilter
-
- All Implemented Interfaces:
java.io.Serializable
,FileFilter
public class SuffixFileFilter extends java.lang.Object implements FileFilter, java.io.Serializable
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
Fields Modifier and Type Field Description private IOCase
caseSensitivity
Whether the comparison is case sensitive.private static long
serialVersionUID
private java.util.List<java.lang.String>
suffixes
The file name suffixes to search for.
-
Constructor Summary
Constructors Constructor Description SuffixFileFilter(java.lang.String... suffixes)
Constructs a new Suffix file filter for an array of suffixes.SuffixFileFilter(java.util.List<java.lang.String> suffixes)
Constructs a new Suffix file filter for a list of suffixes.SuffixFileFilter(IOCase caseSensitivity, java.lang.String... suffixes)
Constructs a new Suffix file filter for an array of suffixs specifying case-sensitivity.SuffixFileFilter(IOCase caseSensitivity, java.util.List<java.lang.String> suffixes)
Constructs a new Suffix file filter for a list of suffixes specifying case-sensitivity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accept(FileSelectInfo fileSelectInfo)
Checks to see if the file name ends with the suffix.java.lang.String
toString()
Provides a String representation of this file filter.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
caseSensitivity
private final IOCase caseSensitivity
Whether the comparison is case sensitive.
-
suffixes
private final java.util.List<java.lang.String> suffixes
The file name suffixes to search for.
-
-
Constructor Detail
-
SuffixFileFilter
public SuffixFileFilter(java.util.List<java.lang.String> suffixes)
Constructs a new Suffix file filter for a list of suffixes.- Parameters:
suffixes
- the suffixes to allow, must not be null
-
SuffixFileFilter
public SuffixFileFilter(IOCase caseSensitivity, java.util.List<java.lang.String> suffixes)
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
public SuffixFileFilter(java.lang.String... suffixes)
Constructs a new Suffix file filter for an array of suffixes.- Parameters:
suffixes
- the suffixes to allow, must not be null
-
SuffixFileFilter
public SuffixFileFilter(IOCase caseSensitivity, java.lang.String... suffixes)
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 Detail
-
accept
public boolean accept(FileSelectInfo fileSelectInfo)
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
public java.lang.String toString()
Provides a String representation of this file filter.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a String representation
-
-