Package org.apache.commons.io.file
Class CountingPathVisitor
java.lang.Object
java.nio.file.SimpleFileVisitor<Path>
org.apache.commons.io.file.SimplePathVisitor
org.apache.commons.io.file.CountingPathVisitor
- All Implemented Interfaces:
- FileVisitor<Path>,- PathVisitor
- Direct Known Subclasses:
- AccumulatorPathVisitor,- CleaningPathVisitor,- CopyDirectoryVisitor,- DeletingPathVisitor
Counts files, directories, and sizes, as a visit proceeds.
- Since:
- 2.7
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classBuilds instances ofCountingPathVisitor.static classBuilds instances ofCountingPathVisitor.
- 
Constructor SummaryConstructorsConstructorDescriptionCountingPathVisitor(Counters.PathCounters pathCounters) Constructs a new instance.CountingPathVisitor(Counters.PathCounters pathCounters, PathFilter fileFilter, PathFilter directoryFilter) Constructs a new instance.CountingPathVisitor(Counters.PathCounters pathCounters, PathFilter fileFilter, PathFilter directoryFilter, IOBiFunction<Path, IOException, FileVisitResult> visitFileFailed) Deprecated.
- 
Method SummaryModifier and TypeMethodDescriptionprotected booleanaccept(Path file, BasicFileAttributes attributes) Tests whether the given file is accepted by the file filter.booleanGets the visitation counts.inthashCode()postVisitDirectory(Path dir, IOException exc) preVisitDirectory(Path dir, BasicFileAttributes attributes) toString()protected voidupdateDirCounter(Path dir, IOException exc) Updates the counter for visiting the given directory.protected voidupdateFileCounters(Path file, BasicFileAttributes attributes) Updates the counters for visiting the given file.visitFile(Path file, BasicFileAttributes attributes) static CountingPathVisitorConstructs a new instance configured with aBigIntegerCounters.PathCounters.static CountingPathVisitorConstructs a new instance configured with alongCounters.PathCounters.Methods inherited from class org.apache.commons.io.file.SimplePathVisitorvisitFileFailed
- 
Constructor Details- 
CountingPathVisitorConstructs a new instance.- Parameters:
- pathCounters- How to count path visits.
- See Also:
 
- 
CountingPathVisitorpublic CountingPathVisitor(Counters.PathCounters pathCounters, PathFilter fileFilter, PathFilter directoryFilter) Constructs a new instance.- Parameters:
- pathCounters- How to count path visits.
- fileFilter- Filters which files to count.
- directoryFilter- Filters which directories to count.
- Since:
- 2.9.0
- See Also:
 
- 
CountingPathVisitor@Deprecated public CountingPathVisitor(Counters.PathCounters pathCounters, PathFilter fileFilter, PathFilter directoryFilter, IOBiFunction<Path, IOException, FileVisitResult> visitFileFailed) Deprecated.Constructs a new instance.- Parameters:
- pathCounters- How to count path visits.
- fileFilter- Filters which files to count.
- directoryFilter- Filters which directories to count.
- visitFileFailed- Called on- SimplePathVisitor.visitFileFailed(Path, IOException).
- Since:
- 2.12.0
 
 
- 
- 
Method Details- 
withBigIntegerCountersConstructs a new instance configured with aBigIntegerCounters.PathCounters.- Returns:
- a new instance configured with a BigIntegerCounters.PathCounters.
 
- 
withLongCountersConstructs a new instance configured with alongCounters.PathCounters.- Returns:
- a new instance configured with a longCounters.PathCounters.
 
- 
acceptTests whether the given file is accepted by the file filter.- Parameters:
- file- the visited file.
- attributes- the visited file attributes.
- Returns:
- true to copy the given file, false if not.
- Since:
- 2.20.0
 
- 
equals
- 
getPathCountersGets the visitation counts.- Returns:
- the visitation counts.
 
- 
hashCode
- 
postVisitDirectory- Specified by:
- postVisitDirectoryin interface- FileVisitor<Path>
- Overrides:
- postVisitDirectoryin class- SimpleFileVisitor<Path>
- Throws:
- IOException
 
- 
preVisitDirectorypublic FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attributes) throws IOException - Specified by:
- preVisitDirectoryin interface- FileVisitor<Path>
- Overrides:
- preVisitDirectoryin class- SimpleFileVisitor<Path>
- Throws:
- IOException
 
- 
toString
- 
updateDirCounterUpdates the counter for visiting the given directory.- Parameters:
- dir- the visited directory.
- exc- Encountered exception.
- Since:
- 2.9.0
 
- 
updateFileCountersUpdates the counters for visiting the given file.- Parameters:
- file- the visited file.
- attributes- the visited file attributes.
 
- 
visitFile- Specified by:
- visitFilein interface- FileVisitor<Path>
- Overrides:
- visitFilein class- SimpleFileVisitor<Path>
- Throws:
- IOException
 
 
- 
CountingPathVisitor.Builder.