public class TreeCopier extends Object implements FileVisitor<Path>
FileVisitor that copies a file tree.| Modifier and Type | Method and Description |
|---|---|
static void |
copy(Path source,
Path target)
Deeply copies the contents of the directory given by
source into the existing
directory given by target. |
static Path |
copyDir(Path source,
Path targetParent)
Deeply copies the directory given by
source into a directory with the same name located in an existing
parent directory given by targetParent. |
FileVisitResult |
postVisitDirectory(Path dir,
IOException exception) |
FileVisitResult |
preVisitDirectory(Path dir,
BasicFileAttributes attributes) |
FileVisitResult |
visitFile(Path file,
BasicFileAttributes attributes) |
FileVisitResult |
visitFileFailed(Path file,
IOException exception) |
public static Path copyDir(Path source, Path targetParent) throws IOException
source into a directory with the same name located in an existing
parent directory given by targetParent. A new directory will be created if it does not exists yet,
otherwise its contents will be overwritten.source - The source directory.targetParent - The target's parent directory. Must already exist.IOExceptionpublic static void copy(Path source, Path target) throws IOException
source into the existing
directory given by target. The method overwrites any existing content.source - The source directory.target - The target directory. Must already exist.IOExceptionpublic FileVisitResult visitFile(Path file, BasicFileAttributes attributes) throws IOException
visitFile in interface FileVisitor<Path>IOExceptionpublic FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attributes) throws IOException
preVisitDirectory in interface FileVisitor<Path>IOExceptionpublic FileVisitResult postVisitDirectory(Path dir, IOException exception) throws IOException
postVisitDirectory in interface FileVisitor<Path>IOExceptionpublic FileVisitResult visitFileFailed(Path file, IOException exception)
visitFileFailed in interface FileVisitor<Path>Copyright © 2014–2017 European Space Agency (ESA). All rights reserved.