? AccumulatorPathVisitor
java.lang.Object
java.nio.file.SimpleFileVisitor<Path>
org.apache.commons.io.file.SimplePathVisitor
org.apache.commons.io.file.CountingPathVisitor
org.apache.commons.io.file.AccumulatorPathVisitor
- ????????:
FileVisitor<Path>
,PathVisitor
Accumulates normalized paths during visitation.
Use with care on large file trees as each visited Path element is remembered.
Example
Path dir = Paths.get(""); // We are interested in files older than one day long cutoff = System.currentTimeMillis() - (24 * 60 * 60 * 1000); AccumulatorPathVisitor visitor = AccumulatorPathVisitor.withLongCounters(new AgeFileFilter(cutoff)); // // 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());
- ???????:
- 2.7
-
?????
????????Constructs a new instance.AccumulatorPathVisitor
(Counters.PathCounters pathCounter) Constructs a new instance that counts file system elements.AccumulatorPathVisitor
(Counters.PathCounters pathCounter, PathFilter fileFilter, PathFilter dirFilter) Constructs a new instance. -
????
??????????boolean
Gets the list of visited directories.Gets the list of visited files.int
hashCode()
relativizeDirectories
(Path parent, boolean sort, Comparator<? super Path> comparator) Relativizes each directory path withPath.relativize(Path)
against the givenparent
, optionally sorting the result.relativizeFiles
(Path parent, boolean sort, Comparator<? super Path> comparator) Relativizes each file path withPath.relativize(Path)
against the givenparent
, optionally sorting the result.protected void
updateDirCounter
(Path dir, IOException exc) Updates the counter for visiting the given directory.protected void
updateFileCounters
(Path file, BasicFileAttributes attributes) Updates the counters for visiting the given file.static AccumulatorPathVisitor
Creates a new instance configured with a BigIntegerCounters.PathCounters
.static AccumulatorPathVisitor
withBigIntegerCounters
(PathFilter fileFilter, PathFilter dirFilter) Creates a new instance configured with a BigIntegerCounters.PathCounters
.static AccumulatorPathVisitor
Creates a new instance configured with a longCounters.PathCounters
.static AccumulatorPathVisitor
withLongCounters
(PathFilter fileFilter, PathFilter dirFilter) Creates a new instance configured with a longCounters.PathCounters
.??????? org.apache.commons.io.file.CountingPathVisitor
getPathCounters, postVisitDirectory, preVisitDirectory, toString, visitFile
??????? java.nio.file.SimpleFileVisitor
visitFileFailed
???????? java.nio.file.FileVisitor
visitFileFailed
-
???????
-
AccumulatorPathVisitor
public AccumulatorPathVisitor()Constructs a new instance.- ???????:
- 2.9.0
-
AccumulatorPathVisitor
Constructs a new instance that counts file system elements.- ??:
pathCounter
- How to count path visits.
-
AccumulatorPathVisitor
public AccumulatorPathVisitor(Counters.PathCounters pathCounter, PathFilter fileFilter, PathFilter dirFilter) Constructs a new instance.- ??:
pathCounter
- How to count path visits.fileFilter
- Filters which files to count.dirFilter
- Filters which directories to count.- ???????:
- 2.9.0
-
-
??????
-
withBigIntegerCounters
Creates a new instance configured with a BigIntegerCounters.PathCounters
.- ??:
- a new instance configured with a BigInteger
Counters.PathCounters
.
-
withBigIntegerCounters
public static AccumulatorPathVisitor withBigIntegerCounters(PathFilter fileFilter, PathFilter dirFilter) Creates a new instance configured with a BigIntegerCounters.PathCounters
.- ??:
fileFilter
- Filters files to accumulate and count.dirFilter
- Filters directories to accumulate and count.- ??:
- a new instance configured with a long
Counters.PathCounters
. - ???????:
- 2.9.0
-
withLongCounters
Creates a new instance configured with a longCounters.PathCounters
.- ??:
- a new instance configured with a long
Counters.PathCounters
.
-
withLongCounters
Creates a new instance configured with a longCounters.PathCounters
.- ??:
fileFilter
- Filters files to accumulate and count.dirFilter
- Filters directories to accumulate and count.- ??:
- a new instance configured with a long
Counters.PathCounters
. - ???????:
- 2.9.0
-
equals
- ??:
equals
???CountingPathVisitor
-
getDirList
Gets the list of visited directories.- ??:
- the list of visited directories.
-
getFileList
Gets the list of visited files.- ??:
- the list of visited files.
-
hashCode
- ??:
hashCode
???CountingPathVisitor
-
relativizeDirectories
public List<Path> relativizeDirectories(Path parent, boolean sort, Comparator<? super Path> comparator) Relativizes each directory path withPath.relativize(Path)
against the givenparent
, optionally sorting the result.- ??:
parent
- A parent pathsort
- Whether to sortcomparator
- How to sort, null uses default sorting.- ??:
- A new list
-
relativizeFiles
Relativizes each file path withPath.relativize(Path)
against the givenparent
, optionally sorting the result.- ??:
parent
- A parent pathsort
- Whether to sortcomparator
- How to sort, null uses default sorting.- ??:
- A new list
-
updateDirCounter
???????:CountingPathVisitor
Updates the counter for visiting the given directory.- ??:
updateDirCounter
???CountingPathVisitor
- ??:
dir
- the visited directory.exc
- Encountered exception.
-
updateFileCounters
???????:CountingPathVisitor
Updates the counters for visiting the given file.- ??:
updateFileCounters
???CountingPathVisitor
- ??:
file
- the visited file.attributes
- the visited file attributes.
-