org.apache.commons.io.file

## Class CopyDirectoryVisitor

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

- All Implemented Interfaces:
    FileVisitor<Path>

      public class CopyDirectoryVisitor
      extends CountingPathVisitor

  Copies a source directory to a target directory.
  Since:
    2.7

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CopyDirectoryVisitor(Counters.PathCounters pathCounter, Path sourceDirectory, Path targetDirectory, CopyOption... copyOptions)` Constructs a new visitor that deletes files except for the files and directories explicitly given.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `FileVisitResult` | `preVisitDirectory(Path directory, BasicFileAttributes attributes)`
    `FileVisitResult` | `visitFile(Path sourceFile, BasicFileAttributes attributes)`

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

      `equals, getPathCounters, hashCode, postVisitDirectory, toString, updateFileCounters, withBigIntegerCounters, withLongCounters`

    - ### 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

    - #### CopyDirectoryVisitor

          public CopyDirectoryVisitor(Counters.PathCounters pathCounter,
                                      Path sourceDirectory,
                                      Path targetDirectory,
                                      CopyOption... copyOptions)

      Constructs a new visitor that deletes files except for the files and directories explicitly given.
      Parameters:
        `pathCounter` - How to count visits.
        `sourceDirectory` - The source directory
        `targetDirectory` - The target directory
        `copyOptions` - Specifies how the copying should be done.

  - ### Method Detail

    - #### preVisitDirectory

          public FileVisitResult preVisitDirectory(Path directory,
                                                   BasicFileAttributes attributes)
                                            throws IOException

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

    - #### visitFile

          public FileVisitResult visitFile(Path sourceFile,
                                           BasicFileAttributes attributes)
                                    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.