|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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]); }
FileFilterUtils.prefixFileFilter(String)
,
FileFilterUtils.prefixFileFilter(String, IOCase)
,
Serialized FormConstructor Summary | |
---|---|
PrefixFileFilter(List<String> prefixes)
Constructs a new Prefix file filter for a list of prefixes. |
|
PrefixFileFilter(List<String> 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 nullpublic 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 nullpublic 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<String> prefixes)
prefixes
- the prefixes to allow, must not be null
IllegalArgumentException
- if the prefix list is null
ClassCastException
- if the list does not contain Stringspublic PrefixFileFilter(List<String> 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 StringsMethod Detail |
---|
public boolean accept(File file)
accept
in interface FileFilter
accept
in interface IOFileFilter
accept
in class AbstractFileFilter
file
- the File to check
public boolean accept(File file, String name)
accept
in interface FilenameFilter
accept
in interface IOFileFilter
accept
in class AbstractFileFilter
file
- 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 |