public class PrefixFileFilter extends AbstractFileFilter implements Serializable
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 and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
public PrefixFileFilter(String prefix)
prefix - the prefix to allow, must not be nullIllegalArgumentException - 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-sensitiveIllegalArgumentException - 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 nullIllegalArgumentException - 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-sensitiveIllegalArgumentException - if the prefix is nullpublic PrefixFileFilter(List prefixes)
prefixes - the prefixes to allow, must not be nullIllegalArgumentException - if the prefix list is nullClassCastException - if the list does not contain Stringspublic PrefixFileFilter(List prefixes, IOCase caseSensitivity)
prefixes - the prefixes to allow, must not be nullcaseSensitivity - how to handle case sensitivity, null means case-sensitiveIllegalArgumentException - if the prefix list is nullClassCastException - if the list does not contain Stringspublic boolean accept(File file)
accept in interface IOFileFilteraccept in interface FileFilteraccept in class AbstractFileFilterfile - the File to checkpublic boolean accept(File file, String name)
accept in interface IOFileFilteraccept in interface FilenameFilteraccept in class AbstractFileFilterfile - the File directoryname - the filenamepublic String toString()
toString in class AbstractFileFilterCopyright © 2001–2019 KnowGate. All rights reserved.