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]);
}
| 构造器和说明 |
|---|
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.
|
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)
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<String> 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<String> 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 在接口中 FileFilteraccept 在接口中 IOFileFilteraccept 在类中 AbstractFileFilterfile - the File to checkpublic boolean accept(File file, String name)
accept 在接口中 FilenameFilteraccept 在接口中 IOFileFilteraccept 在类中 AbstractFileFilterfile - the File directoryname - the filenamepublic String toString()
toString 在类中 AbstractFileFilter