? WildcardFilter
java.lang.Object
org.apache.commons.io.filefilter.AbstractFileFilter
org.apache.commons.io.filefilter.WildcardFilter
- ????????:
FileFilter
,FilenameFilter
,Serializable
,FileVisitor<Path>
,PathFilter
,PathVisitor
,IOFileFilter
????
Use WildcardFileFilter. Deprecated as this class performs directory
filtering which it shouldn't do, but that can't be removed due to compatibility.
Filters files using the supplied wildcards.
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:
Using Classic IO
File dir = new File("."); FileFilter fileFilter = new WildcardFilter("*test*.java~*~"); File[] files = dir.listFiles(fileFilter); for (String file : files) { System.out.println(file); }
Using NIO
final Path dir = Paths.get(""); 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());
- ???????:
- 1.1
- ????:
-
????
???????? org.apache.commons.io.filefilter.IOFileFilter
EMPTY_STRING_ARRAY
-
?????
????????WildcardFilter
(String wildcard) ????Construct a new case-sensitive wildcard filter for a single wildcard.WildcardFilter
(String... wildcards) ????Construct a new case-sensitive wildcard filter for an array of wildcards.WildcardFilter
(List<String> wildcards) ????Construct a new case-sensitive wildcard filter for a list of wildcards. -
????
??????????boolean
????Checks to see if the file name matches one of the wildcards.boolean
????Checks to see if the file name matches one of the wildcards.accept
(Path file, BasicFileAttributes attributes) ????Checks to see if the file name matches one of the wildcards.??????? org.apache.commons.io.filefilter.AbstractFileFilter
handle, postVisitDirectory, preVisitDirectory, toString, visitFile, visitFileFailed
??????? java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
???????? org.apache.commons.io.filefilter.IOFileFilter
and, negate, or
-
???????
-
WildcardFilter
????Construct a new case-sensitive wildcard filter for a list of wildcards.- ??:
wildcards
- the list of wildcards to match- ??:
IllegalArgumentException
- if the pattern list is nullClassCastException
- if the list does not contain Strings
-
WildcardFilter
????Construct a new case-sensitive wildcard filter for a single wildcard.- ??:
wildcard
- the wildcard to match- ??:
IllegalArgumentException
- if the pattern is null
-
WildcardFilter
????Construct a new case-sensitive wildcard filter for an array of wildcards.- ??:
wildcards
- the array of wildcards to match- ??:
IllegalArgumentException
- if the pattern array is null
-
-
??????
-
accept
????Checks to see if the file name matches one of the wildcards.- ???:
accept
????FileFilter
- ???:
accept
????IOFileFilter
- ??:
accept
???AbstractFileFilter
- ??:
file
- the file to check- ??:
- true if the file name matches one of the wildcards
-
accept
????Checks to see if the file name matches one of the wildcards.- ???:
accept
????IOFileFilter
- ???:
accept
????PathFilter
- ??:
file
- the file to checkattributes
- the file's basic attributes (TODO may be null).- ??:
- true if the file name matches one of the wildcards
- ???????:
- 2.9.0
-
accept
????Checks to see if the file name matches one of the wildcards.- ???:
accept
????FilenameFilter
- ???:
accept
????IOFileFilter
- ??:
accept
???AbstractFileFilter
- ??:
dir
- the file directoryname
- the file name- ??:
- true if the file name matches one of the wildcards
-