|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.apache.commons.io.filefilter.AbstractFileFilter
org.apache.commons.io.filefilter.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]);
}
| Constructor Summary | |
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. |
|
| Method Summary | |
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. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public PrefixFileFilter(String prefix)
prefix - the prefix to allow, must not be null
IllegalArgumentException - if the prefix is nullpublic PrefixFileFilter(String[] 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
IllegalArgumentException - if the prefix array is nullpublic PrefixFileFilter(List prefixes)
prefixes - the prefixes to allow, must not be null
IllegalArgumentException - if the prefix list is null
ClassCastException - if the list does not contain Strings| Method Detail |
public boolean accept(File file)
accept in interface IOFileFilteraccept in class AbstractFileFilterfile - the File to check
public boolean accept(File file,
String name)
accept in interface IOFileFilteraccept in class AbstractFileFilterfile - the File directoryname - the filename
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||