public class CopyDirectoryVisitor extends CountingPathVisitor
| Modifier and Type | Field and Description |
|---|---|
private java.nio.file.CopyOption[] |
copyOptions |
private java.nio.file.Path |
sourceDirectory |
private java.nio.file.Path |
targetDirectory |
EMPTY_STRING_ARRAY| Constructor and Description |
|---|
CopyDirectoryVisitor(Counters.PathCounters pathCounter,
PathFilter fileFilter,
PathFilter dirFilter,
java.nio.file.Path sourceDirectory,
java.nio.file.Path targetDirectory,
java.nio.file.CopyOption... copyOptions)
Constructs a new visitor that deletes files except for the files and directories explicitly given.
|
CopyDirectoryVisitor(Counters.PathCounters pathCounter,
java.nio.file.Path sourceDirectory,
java.nio.file.Path targetDirectory,
java.nio.file.CopyOption... copyOptions)
Constructs a new visitor that deletes files except for the files and directories explicitly given.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
copy(java.nio.file.Path sourceFile,
java.nio.file.Path targetFile)
Copies the sourceFile to the targetFile.
|
boolean |
equals(java.lang.Object obj) |
java.nio.file.CopyOption[] |
getCopyOptions()
Gets the copy options.
|
java.nio.file.Path |
getSourceDirectory()
Gets the source directory.
|
java.nio.file.Path |
getTargetDirectory()
Gets the target directory.
|
int |
hashCode() |
java.nio.file.FileVisitResult |
preVisitDirectory(java.nio.file.Path directory,
java.nio.file.attribute.BasicFileAttributes attributes) |
private java.nio.file.Path |
resolveRelativeAsString(java.nio.file.Path directory)
Relativizes against
sourceDirectory, then resolves against targetDirectory. |
private static java.nio.file.CopyOption[] |
toCopyOption(java.nio.file.CopyOption... copyOptions) |
java.nio.file.FileVisitResult |
visitFile(java.nio.file.Path sourceFile,
java.nio.file.attribute.BasicFileAttributes attributes) |
defaultDirFilter, defaultFileFilter, getPathCounters, postVisitDirectory, toString, updateDirCounter, updateFileCounters, withBigIntegerCounters, withLongCountersvisitFileFailedprivate final java.nio.file.CopyOption[] copyOptions
private final java.nio.file.Path sourceDirectory
private final java.nio.file.Path targetDirectory
public CopyDirectoryVisitor(Counters.PathCounters pathCounter, java.nio.file.Path sourceDirectory, java.nio.file.Path targetDirectory, java.nio.file.CopyOption... copyOptions)
pathCounter - How to count visits.sourceDirectory - The source directorytargetDirectory - The target directorycopyOptions - Specifies how the copying should be done.public CopyDirectoryVisitor(Counters.PathCounters pathCounter, PathFilter fileFilter, PathFilter dirFilter, java.nio.file.Path sourceDirectory, java.nio.file.Path targetDirectory, java.nio.file.CopyOption... copyOptions)
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.private static java.nio.file.CopyOption[] toCopyOption(java.nio.file.CopyOption... copyOptions)
protected void copy(java.nio.file.Path sourceFile,
java.nio.file.Path targetFile)
throws java.io.IOException
sourceFile - the source file.targetFile - the target file.java.io.IOException - if an I/O error occurs.public boolean equals(java.lang.Object obj)
equals in class CountingPathVisitorpublic java.nio.file.CopyOption[] getCopyOptions()
public java.nio.file.Path getSourceDirectory()
public java.nio.file.Path getTargetDirectory()
public int hashCode()
hashCode in class CountingPathVisitorpublic java.nio.file.FileVisitResult preVisitDirectory(java.nio.file.Path directory,
java.nio.file.attribute.BasicFileAttributes attributes)
throws java.io.IOException
preVisitDirectory in interface java.nio.file.FileVisitor<java.nio.file.Path>preVisitDirectory in class CountingPathVisitorjava.io.IOExceptionprivate java.nio.file.Path resolveRelativeAsString(java.nio.file.Path directory)
sourceDirectory, then resolves against targetDirectory.
We have to call Path.toString() relative value because we cannot use paths belonging to different
FileSystems in the Path methods, usually this leads to ProviderMismatchException.directory - the directory to relativize.public java.nio.file.FileVisitResult visitFile(java.nio.file.Path sourceFile,
java.nio.file.attribute.BasicFileAttributes attributes)
throws java.io.IOException
visitFile in interface java.nio.file.FileVisitor<java.nio.file.Path>visitFile in class CountingPathVisitorjava.io.IOException