Package org.esa.snap.core.util.io
Class TreeCopier
- java.lang.Object
-
- org.esa.snap.core.util.io.TreeCopier
-
- All Implemented Interfaces:
FileVisitor<Path>
public class TreeCopier extends Object implements FileVisitor<Path>
AFileVisitor
that copies a file tree.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
copy(Path source, Path target)
Deeply copies the contents of the directory given bysource
into the existing directory given bytarget
.static Path
copyDir(Path source, Path targetParent)
Deeply copies the directory given bysource
into a directory with the same name located in an existing parent directory given bytargetParent
.FileVisitResult
postVisitDirectory(Path dir, IOException exception)
FileVisitResult
preVisitDirectory(Path dir, BasicFileAttributes attributes)
FileVisitResult
visitFile(Path file, BasicFileAttributes attributes)
FileVisitResult
visitFileFailed(Path file, IOException exception)
-
-
-
Method Detail
-
copyDir
public static Path copyDir(Path source, Path targetParent) throws IOException
Deeply copies the directory given bysource
into a directory with the same name located in an existing parent directory given bytargetParent
. A new directory will be created if it does not exists yet, otherwise its contents will be overwritten.- Parameters:
source
- The source directory.targetParent
- The target's parent directory. Must already exist.- Throws:
IOException
-
copy
public static void copy(Path source, Path target) throws IOException
Deeply copies the contents of the directory given bysource
into the existing directory given bytarget
. The method overwrites any existing content.- Parameters:
source
- The source directory.target
- The target directory. Must already exist.- Throws:
IOException
-
visitFile
public FileVisitResult visitFile(Path file, BasicFileAttributes attributes) throws IOException
- Specified by:
visitFile
in interfaceFileVisitor<Path>
- Throws:
IOException
-
preVisitDirectory
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attributes) throws IOException
- Specified by:
preVisitDirectory
in interfaceFileVisitor<Path>
- Throws:
IOException
-
postVisitDirectory
public FileVisitResult postVisitDirectory(Path dir, IOException exception) throws IOException
- Specified by:
postVisitDirectory
in interfaceFileVisitor<Path>
- Throws:
IOException
-
visitFileFailed
public FileVisitResult visitFileFailed(Path file, IOException exception)
- Specified by:
visitFileFailed
in interfaceFileVisitor<Path>
-
-