|
||||||||||
| 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
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]);
}
| Constructor Summary | |
|---|---|
PrefixFileFilter(List prefixes)
Constructs a new Prefix file filter for a list of prefixes. |
|
PrefixFileFilter(List prefixes,
IOCase caseSensitivity)
Constructs a new Prefix file filter for a list of prefixes specifying case-sensitivity. |
|
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. |
|
PrefixFileFilter(String[] prefixes,
IOCase caseSensitivity)
Constructs a new Prefix file filter for any of an array of prefixes specifying case-sensitivity. |
|
PrefixFileFilter(String prefix,
IOCase caseSensitivity)
Constructs a new Prefix file filter for a single prefix specifying case-sensitivity. |
|
| 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. |
String |
toString()
Provide a String representaion of this file filter. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public PrefixFileFilter(String prefix)
prefix - the prefix to allow, must not be null
IllegalArgumentException - if the prefix is null
public PrefixFileFilter(String prefix,
IOCase caseSensitivity)
prefix - the prefix to allow, must not be nullcaseSensitivity - how to handle case sensitivity, null means case-sensitive
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 null
public PrefixFileFilter(String[] prefixes,
IOCase caseSensitivity)
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 nullcaseSensitivity - how to handle case sensitivity, null means case-sensitive
IllegalArgumentException - if the prefix 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
public PrefixFileFilter(List prefixes,
IOCase caseSensitivity)
prefixes - the prefixes to allow, must not be nullcaseSensitivity - how to handle case sensitivity, null means case-sensitive
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 FileFilteraccept in interface IOFileFilteraccept in class AbstractFileFilterfile - the File to check
public boolean accept(File file,
String name)
accept in interface FilenameFilteraccept in interface IOFileFilteraccept in class AbstractFileFilterfile - the File directoryname - the filename
public String toString()
toString in class AbstractFileFilter
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||