org.apache.commons.io.filefilter
Class PrefixFileFilter
- FileFilter, FilenameFilter, IOFileFilter
public class PrefixFileFilter
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]);
}
$Revision: 155419 $ $Date: 2005-02-26 08:02:41 -0500 (Sat, 26 Feb 2005) $- Henri Yandell
- Stephen Colebourne
- Federico Barbieri
- Serge Knystautas
- Peter Donald
private String[] | prefixes- The filename prefixes to search for
|
PrefixFileFilter(List prefixes)- Constructs a new Prefix file filter for a list of prefixes.
|
PrefixFileFilter(String prefix)- Constructs a new Prefix file filter for a single prefix.
|
PrefixFileFilter(String[] prefixes)- Constructs a new Prefix file filter for any of an array of prefixes.
|
boolean | accept(File file)- Checks to see if the filename starts with the prefix.
|
boolean | accept(File file, String name)- Checks to see if the filename starts with the prefix.
|
prefixes
private String[] prefixes
The filename prefixes to search for
PrefixFileFilter
public PrefixFileFilter(List prefixes)
Constructs a new Prefix file filter for a list of prefixes.
prefixes - the prefixes to allow, must not be null
PrefixFileFilter
public PrefixFileFilter(String prefix)
Constructs a new Prefix file filter for a single prefix.
prefix - the prefix to allow, must not be null
PrefixFileFilter
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. This would be inadvisable however.
prefixes - the prefixes to allow, must not be null
accept
public boolean accept(File file)
Checks to see if the filename starts with the prefix.
- accept in interface IOFileFilter
- accept in interface AbstractFileFilter
- true if the filename starts with one of our prefixes
accept
public boolean accept(File file,
String name) Checks to see if the filename starts with the prefix.
- accept in interface IOFileFilter
- accept in interface AbstractFileFilter
file - the File directoryname - the filename
- true if the filename starts with one of our prefixes