Package org.apache.commons.io.file
Class CountingPathVisitor
- java.lang.Object
-
- java.nio.file.SimpleFileVisitor<java.nio.file.Path>
-
- org.apache.commons.io.file.SimplePathVisitor
-
- org.apache.commons.io.file.CountingPathVisitor
-
- All Implemented Interfaces:
java.nio.file.FileVisitor<java.nio.file.Path>
,PathVisitor
- Direct Known Subclasses:
AccumulatorPathVisitor
,CleaningPathVisitor
,CopyDirectoryVisitor
,DeletingPathVisitor
public class CountingPathVisitor extends SimplePathVisitor
Counts files, directories, and sizes, as a visit proceeds.- Since:
- 2.7
-
-
Constructor Summary
Constructors Constructor Description CountingPathVisitor(Counters.PathCounters pathCounter)
Constructs a new instance.CountingPathVisitor(Counters.PathCounters pathCounter, PathFilter fileFilter, PathFilter dirFilter)
Constructs a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Counters.PathCounters
getPathCounters()
Gets the visitation counts.int
hashCode()
java.nio.file.FileVisitResult
postVisitDirectory(java.nio.file.Path dir, java.io.IOException exc)
java.nio.file.FileVisitResult
preVisitDirectory(java.nio.file.Path dir, java.nio.file.attribute.BasicFileAttributes attributes)
java.lang.String
toString()
java.nio.file.FileVisitResult
visitFile(java.nio.file.Path file, java.nio.file.attribute.BasicFileAttributes attributes)
static CountingPathVisitor
withBigIntegerCounters()
Creates a new instance configured with a BigIntegerCounters.PathCounters
.static CountingPathVisitor
withLongCounters()
Creates a new instance configured with a longCounters.PathCounters
.
-
-
-
Constructor Detail
-
CountingPathVisitor
public CountingPathVisitor(Counters.PathCounters pathCounter)
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 Detail
-
withBigIntegerCounters
public static CountingPathVisitor withBigIntegerCounters()
Creates a new instance configured with a BigIntegerCounters.PathCounters
.- Returns:
- a new instance configured with a BigInteger
Counters.PathCounters
.
-
withLongCounters
public static CountingPathVisitor withLongCounters()
Creates a new instance configured with a longCounters.PathCounters
.- Returns:
- a new instance configured with a long
Counters.PathCounters
.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
getPathCounters
public Counters.PathCounters getPathCounters()
Gets the visitation counts.- Returns:
- the visitation counts.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
postVisitDirectory
public java.nio.file.FileVisitResult postVisitDirectory(java.nio.file.Path dir, java.io.IOException exc) throws java.io.IOException
- Specified by:
postVisitDirectory
in interfacejava.nio.file.FileVisitor<java.nio.file.Path>
- Overrides:
postVisitDirectory
in classjava.nio.file.SimpleFileVisitor<java.nio.file.Path>
- Throws:
java.io.IOException
-
preVisitDirectory
public java.nio.file.FileVisitResult preVisitDirectory(java.nio.file.Path dir, java.nio.file.attribute.BasicFileAttributes attributes) throws java.io.IOException
- Specified by:
preVisitDirectory
in interfacejava.nio.file.FileVisitor<java.nio.file.Path>
- Overrides:
preVisitDirectory
in classjava.nio.file.SimpleFileVisitor<java.nio.file.Path>
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
visitFile
public java.nio.file.FileVisitResult visitFile(java.nio.file.Path file, java.nio.file.attribute.BasicFileAttributes attributes) throws java.io.IOException
- Specified by:
visitFile
in interfacejava.nio.file.FileVisitor<java.nio.file.Path>
- Overrides:
visitFile
in classjava.nio.file.SimpleFileVisitor<java.nio.file.Path>
- Throws:
java.io.IOException
-
-