@Deprecated public class WildcardFilter extends AbstractFileFilter implements java.io.Serializable
This filter selects files, but not directories, based on one or more wildcards and using case-sensitive comparison.
The wildcard matcher uses the characters '?' and '*' to represent a
single or multiple wildcard characters.
This is the same as often found on DOS/Unix command lines.
The extension check is case-sensitive.
See FilenameUtils.wildcardMatch(String, String) for more information.
For example:
File dir = FileUtils.current();
FileFilter fileFilter = new WildcardFilter("*test*.java~*~");
File[] files = dir.listFiles(fileFilter);
for (String file : files) {
System.out.println(file);
}
final Path dir = PathUtils.current();
final AccumulatorPathVisitor visitor = AccumulatorPathVisitor.withLongCounters(new WildcardFilter("*test*.java~*~"));
//
// Walk one dir
Files.walkFileTree(dir, Collections.emptySet(), 1, visitor);
System.out.println(visitor.getPathCounters());
System.out.println(visitor.getFileList());
//
visitor.getPathCounters().reset();
//
// Walk dir tree
Files.walkFileTree(dir, visitor);
System.out.println(visitor.getPathCounters());
System.out.println(visitor.getDirList());
System.out.println(visitor.getFileList());
Serialization is deprecated and will be removed in 3.0.
EMPTY_STRING_ARRAY| Constructor and Description |
|---|
WildcardFilter(java.util.List<java.lang.String> wildcards)
Deprecated.
Constructs a new case-sensitive wildcard filter for a list of wildcards.
|
WildcardFilter(java.lang.String... wildcards)
Deprecated.
Constructs a new case-sensitive wildcard filter for an array of wildcards.
|
WildcardFilter(java.lang.String wildcard)
Deprecated.
Constructs a new case-sensitive wildcard filter for a single wildcard.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(java.io.File file)
Deprecated.
Checks to see if the file name matches one of the wildcards.
|
boolean |
accept(java.io.File dir,
java.lang.String name)
Deprecated.
Checks to see if the file name matches one of the wildcards.
|
java.nio.file.FileVisitResult |
accept(java.nio.file.Path file,
java.nio.file.attribute.BasicFileAttributes attributes)
Deprecated.
Checks to see if the file name matches one of the wildcards.
|
postVisitDirectory, preVisitDirectory, toString, visitFile, visitFileFailedequals, getClass, hashCode, notify, notifyAll, wait, wait, waitand, negate, orpublic WildcardFilter(java.util.List<java.lang.String> wildcards)
wildcards - the list of wildcards to matchjava.lang.NullPointerException - if the pattern list is nulljava.lang.ClassCastException - if the list does not contain Stringspublic WildcardFilter(java.lang.String wildcard)
wildcard - the wildcard to matchjava.lang.NullPointerException - if the pattern is nullpublic WildcardFilter(java.lang.String... wildcards)
wildcards - the array of wildcards to matchjava.lang.NullPointerException - if the pattern array is nullpublic boolean accept(java.io.File file)
accept in interface java.io.FileFilteraccept in interface IOFileFilteraccept in class AbstractFileFilterfile - the file to checkpublic boolean accept(java.io.File dir,
java.lang.String name)
accept in interface java.io.FilenameFilteraccept in interface IOFileFilteraccept in class AbstractFileFilterdir - the file directoryname - the file namepublic java.nio.file.FileVisitResult accept(java.nio.file.Path file,
java.nio.file.attribute.BasicFileAttributes attributes)
accept in interface PathFilteraccept in interface IOFileFilterfile - the file to checkattributes - the file's basic attributes (TODO may be null).Copyright © 2010 - 2023 Adobe. All Rights Reserved