@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.
Modifier and Type | Field and Description |
---|---|
private static long |
serialVersionUID
Deprecated.
|
private java.lang.String[] |
wildcards
Deprecated.
The wildcards that will be used to match file names.
|
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.
|
append, append, get, handle, postVisitDirectory, preVisitDirectory, toDefaultFileVisitResult, toFileVisitResult, toString, visitFile, visitFileFailed
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
and, matches, negate, or
private static final long serialVersionUID
private final java.lang.String[] wildcards
public 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.FileFilter
accept
in interface IOFileFilter
accept
in class AbstractFileFilter
file
- the file to checkpublic boolean accept(java.io.File dir, java.lang.String name)
accept
in interface java.io.FilenameFilter
accept
in interface IOFileFilter
accept
in class AbstractFileFilter
dir
- 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 PathFilter
accept
in interface IOFileFilter
file
- the file to checkattributes
- the file's basic attributes (TODO may be null).