org.apache.commons.io.file

## Class DeletingPathVisitor

- 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.DeletingPathVisitor

- All Implemented Interfaces:
    FileVisitor<Path>

      public class DeletingPathVisitor
      extends CountingPathVisitor

  Deletes files and directories as a visit proceeds.
  Since:
    2.7

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DeletingPathVisitor(Counters.PathCounters pathCounter, DeleteOption[] deleteOption, String... skip)` Constructs a new visitor that deletes files except for the files and directories explicitly given.
    `DeletingPathVisitor(Counters.PathCounters pathCounter, String... skip)` Constructs a new visitor that deletes files except for the files and directories explicitly given.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object obj)`
    `int` | `hashCode()`
    `FileVisitResult` | `postVisitDirectory(Path dir, IOException exc)`
    `FileVisitResult` | `preVisitDirectory(Path dir, BasicFileAttributes attrs)`
    `FileVisitResult` | `visitFile(Path file, BasicFileAttributes attrs)`
    `static DeletingPathVisitor` | `withBigIntegerCounters()` Creates a new instance configured with a BigInteger `Counters.PathCounters`.
    `static DeletingPathVisitor` | `withLongCounters()` Creates a new instance configured with a long `Counters.PathCounters`.

    - ### Methods inherited from class org.apache.commons.io.file.CountingPathVisitor

      `getPathCounters, toString, updateFileCounters`

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

      `visitFileFailed`

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

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

- - ### Constructor Detail

    - #### DeletingPathVisitor

          public DeletingPathVisitor(Counters.PathCounters pathCounter,
                                     DeleteOption[] deleteOption,
                                     String... skip)

      Constructs a new visitor that deletes files except for the files and directories explicitly given.
      Parameters:
        `pathCounter` - How to count visits.
        `deleteOption` - options indicating how deletion is handled.
        `skip` - The files to skip deleting.
      Since:
        2.8.0

    - #### DeletingPathVisitor

          public DeletingPathVisitor(Counters.PathCounters pathCounter,
                                     String... skip)

      Constructs a new visitor that deletes files except for the files and directories explicitly given.
      Parameters:
        `pathCounter` - How to count visits.
        `skip` - The files to skip deleting.

  - ### Method Detail

    - #### withBigIntegerCounters

          public static DeletingPathVisitor withBigIntegerCounters()

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

    - #### withLongCounters

          public static DeletingPathVisitor 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 `CountingPathVisitor`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `CountingPathVisitor`

    - #### postVisitDirectory

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

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

    - #### preVisitDirectory

          public FileVisitResult preVisitDirectory(Path dir,
                                                   BasicFileAttributes attrs)
                                            throws IOException

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

    - #### visitFile

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

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

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