Package 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
Copies a source directory to a target directory.
- Since:
- 2.7
-
Constructor Summary
ConstructorDescriptionCopyDirectoryVisitor
(Counters.PathCounters pathCounter, Path sourceDirectory, Path targetDirectory, CopyOption... copyOptions) Constructs a instance that deletes files except for the files and directories explicitly given.CopyDirectoryVisitor
(Counters.PathCounters pathCounter, PathFilter fileFilter, PathFilter dirFilter, Path sourceDirectory, Path targetDirectory, CopyOption... copyOptions) Constructs a instance that deletes files except for the files and directories explicitly given. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Copies the sourceFile to the targetFile.boolean
Gets the copy options.Gets the source directory.Gets the target directory.int
hashCode()
preVisitDirectory
(Path directory, BasicFileAttributes attributes) visitFile
(Path sourceFile, BasicFileAttributes attributes) Methods inherited from class org.apache.commons.io.file.CountingPathVisitor
getPathCounters, postVisitDirectory, toString, updateDirCounter, updateFileCounters, withBigIntegerCounters, withLongCounters
Methods inherited from class org.apache.commons.io.file.SimplePathVisitor
visitFileFailed
-
Constructor Details
-
CopyDirectoryVisitor
public CopyDirectoryVisitor(Counters.PathCounters pathCounter, Path sourceDirectory, Path targetDirectory, CopyOption... copyOptions) Constructs a instance that deletes files except for the files and directories explicitly given.- Parameters:
pathCounter
- How to count visits.sourceDirectory
- The source directorytargetDirectory
- The target directorycopyOptions
- Specifies how the copying should be done.
-
CopyDirectoryVisitor
public CopyDirectoryVisitor(Counters.PathCounters pathCounter, PathFilter fileFilter, PathFilter dirFilter, Path sourceDirectory, Path targetDirectory, CopyOption... copyOptions) Constructs a instance that deletes files except for the files and directories explicitly given.- Parameters:
pathCounter
- How to count visits.fileFilter
- How to filter file paths.dirFilter
- How to filter directory paths.sourceDirectory
- The source directorytargetDirectory
- The target directorycopyOptions
- Specifies how the copying should be done.- Since:
- 2.9.0
-
-
Method Details
-
copy
Copies the sourceFile to the targetFile.- Parameters:
sourceFile
- the source file.targetFile
- the target file.- Throws:
IOException
- if an I/O error occurs.- Since:
- 2.8.0
-
equals
- Overrides:
equals
in classCountingPathVisitor
-
getCopyOptions
Gets the copy options.- Returns:
- the copy options.
- Since:
- 2.8.0
-
getSourceDirectory
Gets the source directory.- Returns:
- the source directory.
- Since:
- 2.8.0
-
getTargetDirectory
Gets the target directory.- Returns:
- the target directory.
- Since:
- 2.8.0
-
hashCode
- Overrides:
hashCode
in classCountingPathVisitor
-
preVisitDirectory
public FileVisitResult preVisitDirectory(Path directory, BasicFileAttributes attributes) throws IOException - Specified by:
preVisitDirectory
in interfaceFileVisitor<Path>
- Overrides:
preVisitDirectory
in classCountingPathVisitor
- Throws:
IOException
-
visitFile
public FileVisitResult visitFile(Path sourceFile, BasicFileAttributes attributes) throws IOException - Specified by:
visitFile
in interfaceFileVisitor<Path>
- Overrides:
visitFile
in classCountingPathVisitor
- Throws:
IOException
-