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
-
Constructor Summary
ConstructorsConstructorDescriptionCountingPathVisitor(Counters.PathCounters pathCounter) Constructs a new instance.CountingPathVisitor(Counters.PathCounters pathCounter, PathFilter fileFilter, PathFilter dirFilter) Constructs a new instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets 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 CountingPathVisitorCreates a new instance configured with a BigIntegerCounters.PathCounters.static CountingPathVisitorCreates a new instance configured with a longCounters.PathCounters.Methods inherited from class java.nio.file.SimpleFileVisitor
visitFileFailedMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.nio.file.FileVisitor
visitFileFailed
-
Constructor Details
-
CountingPathVisitor
Constructs a new instance.- Parameters:
pathCounter- How to count path visits.
-
CountingPathVisitor
public CountingPathVisitor(Counters.PathCounters pathCounter, PathFilter fileFilter, PathFilter dirFilter) Constructs a new instance.- Parameters:
pathCounter- How to count path visits.fileFilter- Filters which files to count.dirFilter- Filters which directories to count.- Since:
- 2.9.0
-
-
Method Details
-
withBigIntegerCounters
Creates a new instance configured with a BigIntegerCounters.PathCounters.- Returns:
- a new instance configured with a BigInteger
Counters.PathCounters.
-
withLongCounters
Creates a new instance configured with a longCounters.PathCounters.- Returns:
- a new instance configured with a long
Counters.PathCounters.
-
equals
-
getPathCounters
Gets the visitation counts.- Returns:
- the visitation counts.
-
hashCode
-
postVisitDirectory
- Specified by:
postVisitDirectoryin interfaceFileVisitor<Path>- Overrides:
postVisitDirectoryin classSimpleFileVisitor<Path>- Throws:
IOException
-
preVisitDirectory
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attributes) throws IOException - Specified by:
preVisitDirectoryin interfaceFileVisitor<Path>- Overrides:
preVisitDirectoryin classSimpleFileVisitor<Path>- Throws:
IOException
-
toString
-
updateDirCounter
Updates the counter for visiting the given directory.- Parameters:
dir- the visited directory.exc- Encountered exception.- Since:
- 2.9.0
-
updateFileCounters
Updates the counters for visiting the given file.- Parameters:
file- the visited file.attributes- the visited file attributes.
-
visitFile
- Specified by:
visitFilein interfaceFileVisitor<Path>- Overrides:
visitFilein classSimpleFileVisitor<Path>- Throws:
IOException
-