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>, PathVisitor

      public class CopyDirectoryVisitor
      extends CountingPathVisitor

  Copies a source directory to a target directory.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.commons.io.file.CountingPathVisitor

      `CountingPathVisitor.AbstractBuilder<T,B extends CountingPathVisitor.AbstractBuilder<T,B>>, CountingPathVisitor.Builder`

  - ### Field Summary

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

      `EMPTY_STRING_ARRAY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CopyDirectoryVisitor(Counters.PathCounters pathCounter, PathFilter fileFilter, PathFilter dirFilter, Path sourceDirectory, Path targetDirectory, CopyOption... copyOptions)` Constructs an instance that copies files matching the given file and directory filters.
    `CopyDirectoryVisitor(Counters.PathCounters pathCounter, Path sourceDirectory, Path targetDirectory, CopyOption... copyOptions)` Constructs an instance that copies all files.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `copy(Path sourceFile, Path targetFile)` Copies the sourceFile to the targetFile.
    `boolean` | `equals(Object obj)`
    `CopyOption[]` | `getCopyOptions()` Gets the copy options.
    `Path` | `getSourceDirectory()` Gets the source directory.
    `Path` | `getTargetDirectory()` Gets the target directory.
    `int` | `hashCode()`
    `FileVisitResult` | `preVisitDirectory(Path directory, BasicFileAttributes attributes)`
    `FileVisitResult` | `visitFile(Path sourceFile, BasicFileAttributes attributes)`

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

      `accept, defaultDirectoryFilter, defaultDirectoryTransformer, defaultFileFilter, defaultPathCounters, getPathCounters, postVisitDirectory, toString, updateDirCounter, updateFileCounters, withBigIntegerCounters, withLongCounters`

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

      `visitFileFailed`

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

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

- - ### Constructor Detail

    - #### CopyDirectoryVisitor

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

      Constructs an instance that copies files matching the given file and directory filters.
      Parameters:
        `pathCounter` - How to count visits.
        `fileFilter` - How to filter file paths.
        `dirFilter` - How to filter directory paths.
        `sourceDirectory` - The source directory
        `targetDirectory` - The target directory
        `copyOptions` - Specifies how the copying should be done.

    - #### CopyDirectoryVisitor

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

      Constructs an instance that copies all files.
      Parameters:
        `pathCounter` - How to count visits.
        `sourceDirectory` - The source directory
        `targetDirectory` - The target directory
        `copyOptions` - Specifies how the copying should be done.

  - ### Method Detail

    - #### copy

          protected void copy(Path sourceFile,
                              Path targetFile)
                       throws IOException

      Copies the sourceFile to the targetFile.
      Parameters:
        `sourceFile` - the source file.
        `targetFile` - the target file.
      Throws:
        `IOException` - if an I/O error occurs.

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `CountingPathVisitor`

    - #### getCopyOptions

          public CopyOption[] getCopyOptions()

      Gets the copy options.
      Returns:
        the copy options.

    - #### getSourceDirectory

          public Path getSourceDirectory()

      Gets the source directory.
      Returns:
        the source directory.

    - #### getTargetDirectory

          public Path getTargetDirectory()

      Gets the target directory.
      Returns:
        the target directory.

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `CountingPathVisitor`

    - #### preVisitDirectory

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

      Specified by:
        `preVisitDirectory` in interface `FileVisitor<Path>`
      Overrides:
        `preVisitDirectory` in class `CountingPathVisitor`
      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`