org.apache.commons.io.filefilter
Class NameFileFilter
- FileFilter, FilenameFilter, IOFileFilter
public class NameFileFilter
Filters filenames for a certain name.
For example, to print all files and directories in the
current directory whose name is
Test
:
File dir = new File(".");
String[] files = dir.list( new NameFileFilter("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[] | names - The filenames to search for
|
NameFileFilter(List names) - Constructs a new name file filter for a list of names.
|
NameFileFilter(String name) - Constructs a new name file filter for a single name.
|
NameFileFilter(String[] names) - Constructs a new name file filter for any of an array of names.
|
boolean | accept(File file) - Checks to see if the filename matches.
|
boolean | accept(File file, String name) - Checks to see if the filename matches.
|
names
private String[] names
The filenames to search for
NameFileFilter
public NameFileFilter(List names)
Constructs a new name file filter for a list of names.
names
- the names to allow, must not be null
NameFileFilter
public NameFileFilter(String name)
Constructs a new name file filter for a single name.
name
- the name to allow, must not be null
NameFileFilter
public NameFileFilter(String[] names)
Constructs a new name file filter for any of an array of names.
The array is not cloned, so could be changed after constructing the
instance. This would be inadvisable however.
names
- the names to allow, must not be null
accept
public boolean accept(File file,
String name)
Checks to see if the filename matches.
- accept in interface IOFileFilter
- accept in interface AbstractFileFilter
file
- the File directoryname
- the filename
- true if the filename matches