| java.lang.Object org.apache.commons.io.filefilter.AbstractFileFilter org.apache.commons.io.filefilter.PrefixFileFilter
PrefixFileFilter | public class PrefixFileFilter extends AbstractFileFilter (Code) | | Filters filenames for a certain prefix.
For example, to print all files and directories in the
current directory whose name starts with Test :
File dir = new File(".");
String[] files = dir.list( new PrefixFileFilter("Test") );
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 | PrefixFileFilter(String prefix) Constructs a new Prefix file filter for a single prefix. | public | PrefixFileFilter(String[] prefixes) 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. | public | PrefixFileFilter(List prefixes) Constructs a new Prefix file filter for a list of prefixes. |
Method Summary | |
public boolean | accept(File file) Checks to see if the filename starts with the prefix. | public boolean | accept(File file, String name) Checks to see if the filename starts with the prefix. |
PrefixFileFilter | public PrefixFileFilter(String prefix)(Code) | | Constructs a new Prefix file filter for a single prefix.
Parameters: prefix - the prefix to allow, must not be null throws: IllegalArgumentException - if the prefix is null |
PrefixFileFilter | public PrefixFileFilter(String[] prefixes)(Code) | | 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 throws: IllegalArgumentException - if the prefix array is null |
PrefixFileFilter | public PrefixFileFilter(List prefixes)(Code) | | Constructs a new Prefix file filter for a list of prefixes.
Parameters: prefixes - the prefixes to allow, must not be null throws: IllegalArgumentException - if the prefix 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 starts with the prefix.
Parameters: file - the File to check true if the filename starts with one of our prefixes |
accept | public boolean accept(File file, String name)(Code) | | Checks to see if the filename starts with the prefix.
Parameters: file - the File directory Parameters: name - the filename true if the filename starts with one of our prefixes |
|
|