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>
  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 and Description
    `CountingPathVisitor(Counters.PathCounters pathCounter)` Constructs a new instance.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object obj)`
    `Counters.PathCounters` | `getPathCounters()` Gets the visitation counts.
    `int` | `hashCode()`
    `FileVisitResult` | `postVisitDirectory(Path dir, IOException exc)`
    `String` | `toString()`
    `protected void` | `updateFileCounters(Path file, BasicFileAttributes attributes)` Updates the counters for visiting the given file.
    `FileVisitResult` | `visitFile(Path file, BasicFileAttributes attributes)`
    `static CountingPathVisitor` | `withBigIntegerCounters()` Creates a new instance configured with a BigInteger `Counters.PathCounters`.
    `static CountingPathVisitor` | `withLongCounters()` Creates a new instance configured with a long `Counters.PathCounters`.

    - ### Methods inherited from class java.nio.file.SimpleFileVisitor

      `preVisitDirectory, visitFileFailed`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### CountingPathVisitor

          public CountingPathVisitor(Counters.PathCounters pathCounter)

      Constructs a new instance.
      Parameters:
        `pathCounter` - How to count path visits.

  - ### Method Detail

    - #### withBigIntegerCounters

          public static CountingPathVisitor withBigIntegerCounters()

      Creates a new instance configured with a BigInteger `Counters.PathCounters`.
      Returns:
        a new instance configured with a BigInteger `Counters.PathCounters`.

    - #### withLongCounters

          public static CountingPathVisitor withLongCounters()

      Creates a new instance configured with a long `Counters.PathCounters`.
      Returns:
        a new instance configured with a long `Counters.PathCounters`.

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### getPathCounters

          public Counters.PathCounters getPathCounters()

      Gets the visitation counts.
      Returns:
        the visitation counts.

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### postVisitDirectory

          public FileVisitResult postVisitDirectory(Path dir,
                                                    IOException exc)
                                             throws IOException

      Specified by:
        `postVisitDirectory` in interface `FileVisitor<Path>`
      Overrides:
        `postVisitDirectory` in class `SimpleFileVisitor<Path>`
      Throws:
        `IOException`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### updateFileCounters

          protected void updateFileCounters(Path file,
                                            BasicFileAttributes attributes)

      Updates the counters for visiting the given file.
      Parameters:
        `file` - the visited file.
        `attributes` - the visited file attributes.

    - #### visitFile

          public FileVisitResult visitFile(Path file,
                                           BasicFileAttributes attributes)
                                    throws IOException

      Specified by:
        `visitFile` in interface `FileVisitor<Path>`
      Overrides:
        `visitFile` in class `SimpleFileVisitor<Path>`
      Throws:
        `IOException`

Copyright © 2002–2020 The Apache Software Foundation. All rights reserved.