| java.lang.Object org.apache.commons.io.filefilter.AbstractFileFilter org.apache.commons.io.filefilter.SuffixFileFilter
SuffixFileFilter | public class SuffixFileFilter extends AbstractFileFilter (Code) | | Filters files based on the suffix (what the filename 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:
File dir = new File(".");
String[] files = dir.list( new SuffixFileFilter(".java") );
for (int i = 0; i < files.length; i++) {
System.out.println(files[i]);
}
since: Commons IO 1.0 version: $Revision: 471628 $ $Date: 2006-11-06 05:06:45 +0100 (Mo, 06 Nov 2006) $ author: Stephen Colebourne author: Federico Barbieri author: Serge Knystautas author: Peter Donald |
Constructor Summary | |
public | SuffixFileFilter(String suffix) Constructs a new Suffix file filter for a single extension. | public | SuffixFileFilter(String[] suffixes) Constructs a new Suffix file filter for an array of suffixs.
The array is not cloned, so could be changed after constructing the
instance. | public | SuffixFileFilter(List suffixes) Constructs a new Suffix file filter for a list of suffixes. |
Method Summary | |
public boolean | accept(File file) Checks to see if the filename ends with the suffix. | public boolean | accept(File file, String name) Checks to see if the filename ends with the suffix. |
SuffixFileFilter | public SuffixFileFilter(String suffix)(Code) | | Constructs a new Suffix file filter for a single extension.
Parameters: suffix - the suffix to allow, must not be null throws: IllegalArgumentException - if the suffix is null |
SuffixFileFilter | public SuffixFileFilter(String[] suffixes)(Code) | | Constructs a new Suffix file filter for an array of suffixs.
The array is not cloned, so could be changed after constructing the
instance. This would be inadvisable however.
Parameters: suffixes - the suffixes to allow, must not be null throws: IllegalArgumentException - if the suffix array is null |
SuffixFileFilter | public SuffixFileFilter(List suffixes)(Code) | | Constructs a new Suffix file filter for a list of suffixes.
Parameters: suffixes - the suffixes to allow, must not be null throws: IllegalArgumentException - if the suffix list is null throws: ClassCastException - if the list does not contain Strings |
accept | public boolean accept(File file)(Code) | | Checks to see if the filename ends with the suffix.
Parameters: file - the File to check true if the filename ends with one of our suffixes |
accept | public boolean accept(File file, String name)(Code) | | Checks to see if the filename ends with the suffix.
Parameters: file - the File directory Parameters: name - the filename true if the filename ends with one of our suffixes |
|
|