? SuffixFileFilter
java.lang.Object
org.apache.commons.io.filefilter.AbstractFileFilter
org.apache.commons.io.filefilter.SuffixFileFilter
- ????????:
FileFilter
,FilenameFilter
,Serializable
,FileVisitor<Path>
,PathFilter
,PathVisitor
,IOFileFilter
Filters files based on the suffix (what the file name ends with).
This is used in retrieving all the files of a particular type.
For example, to retrieve and print all *.java
files
in the current directory:
Using Classic IO
File dir = new File("."); String[] files = dir.list(new SuffixFileFilter(".java")); for (String file : files) { System.out.println(file); }
Using NIO
final Path dir = Paths.get(""); final AccumulatorPathVisitor visitor = AccumulatorPathVisitor.withLongCounters(new SuffixFileFilter(".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());
-
????
???????? org.apache.commons.io.filefilter.IOFileFilter
EMPTY_STRING_ARRAY
-
?????
????????SuffixFileFilter
(String suffix) Constructs a new Suffix file filter for a single extension.SuffixFileFilter
(String... suffixes) Constructs a new Suffix file filter for an array of suffixes.SuffixFileFilter
(String[] suffixes, IOCase caseSensitivity) Constructs a new Suffix file filter for an array of suffixes specifying case-sensitivity.SuffixFileFilter
(String suffix, IOCase caseSensitivity) Constructs a new Suffix file filter for a single extension specifying case-sensitivity.SuffixFileFilter
(List<String> suffixes) Constructs a new Suffix file filter for a list of suffixes.SuffixFileFilter
(List<String> suffixes, IOCase caseSensitivity) Constructs a new Suffix file filter for a list of suffixes specifying case-sensitivity. -
????
??????????boolean
Checks to see if the file name ends with the suffix.boolean
Checks to see if the file name ends with the suffix.accept
(Path file, BasicFileAttributes attributes) Checks to see if the file name ends with the suffix.toString()
Provide a String representation of this file filter.??????? org.apache.commons.io.filefilter.AbstractFileFilter
handle, postVisitDirectory, preVisitDirectory, visitFile, visitFileFailed
??????? java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
???????? org.apache.commons.io.filefilter.IOFileFilter
and, negate, or
-
???????
-
SuffixFileFilter
Constructs a new Suffix file filter for a list of suffixes.- ??:
suffixes
- the suffixes to allow, must not be null- ??:
IllegalArgumentException
- if the suffix list is nullClassCastException
- if the list does not contain Strings
-
SuffixFileFilter
Constructs a new Suffix file filter for a list of suffixes specifying case-sensitivity.- ??:
suffixes
- the suffixes to allow, must not be nullcaseSensitivity
- how to handle case sensitivity, null means case-sensitive- ??:
IllegalArgumentException
- if the suffix list is nullClassCastException
- if the list does not contain Strings- ???????:
- 1.4
-
SuffixFileFilter
Constructs a new Suffix file filter for a single extension.- ??:
suffix
- the suffix to allow, must not be null- ??:
IllegalArgumentException
- if the suffix is null
-
SuffixFileFilter
Constructs a new Suffix file filter for an array of suffixes.The array is not cloned, so could be changed after constructing the instance. This would be inadvisable however.
- ??:
suffixes
- the suffixes to allow, must not be null- ??:
IllegalArgumentException
- if the suffix array is null
-
SuffixFileFilter
Constructs a new Suffix file filter for a single extension specifying case-sensitivity.- ??:
suffix
- the suffix to allow, must not be nullcaseSensitivity
- how to handle case sensitivity, null means case-sensitive- ??:
IllegalArgumentException
- if the suffix is null- ???????:
- 1.4
-
SuffixFileFilter
Constructs a new Suffix file filter for an array of suffixes specifying case-sensitivity.- ??:
suffixes
- the suffixes to allow, must not be nullcaseSensitivity
- how to handle case sensitivity, null means case-sensitive- ??:
IllegalArgumentException
- if the suffix array is null- ???????:
- 1.4
-
-
??????
-
accept
Checks to see if the file name ends with the suffix.- ???:
accept
????FileFilter
- ???:
accept
????IOFileFilter
- ??:
accept
???AbstractFileFilter
- ??:
file
- the File to check- ??:
- true if the file name ends with one of our suffixes
-
accept
Checks to see if the file name ends with the suffix.- ???:
accept
????FilenameFilter
- ???:
accept
????IOFileFilter
- ??:
accept
???AbstractFileFilter
- ??:
file
- the File directoryname
- the file name- ??:
- true if the file name ends with one of our suffixes
-
accept
Checks to see if the file name ends with the suffix.- ???:
accept
????IOFileFilter
- ???:
accept
????PathFilter
- ??:
file
- the File to checkattributes
- the file's basic attributes (TODO may be null).- ??:
- true if the file name ends with one of our suffixes
- ???????:
- 2.9.0
-
toString
Provide a String representation of this file filter.- ??:
toString
???AbstractFileFilter
- ??:
- a String representation
-