Package org.spongepowered.api.util.file
Class CopyFileVisitor
- java.lang.Object
-
- java.nio.file.SimpleFileVisitor<Path>
-
- org.spongepowered.api.util.file.CopyFileVisitor
-
- All Implemented Interfaces:
FileVisitor<Path>
public final class CopyFileVisitor extends SimpleFileVisitor<Path>
Represents aFileVisitor
which will create a copy of a directory and its contents.Example usage:
Files.walkFileTree(dir, new CopyFileVisitor(target);
-
-
Constructor Summary
Constructors Constructor Description CopyFileVisitor(Path target, CopyOption... options)
Constructs a newCopyFileVisitor
which will copy the visited file paths to the specified target directory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FileVisitResult
preVisitDirectory(Path dir, BasicFileAttributes attrs)
FileVisitResult
visitFile(Path file, BasicFileAttributes attrs)
-
Methods inherited from class java.nio.file.SimpleFileVisitor
postVisitDirectory, visitFileFailed
-
-
-
-
Constructor Detail
-
CopyFileVisitor
public CopyFileVisitor(Path target, CopyOption... options)
Constructs a newCopyFileVisitor
which will copy the visited file paths to the specified target directory.Note: The target directory must not exist since the visitor will also copy the root directory to the specified location.
- Parameters:
target
- The path to copy the visited files tooptions
- Optional options for the copy operations
-
-
Method Detail
-
preVisitDirectory
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException
- Specified by:
preVisitDirectory
in interfaceFileVisitor<Path>
- Overrides:
preVisitDirectory
in classSimpleFileVisitor<Path>
- Throws:
IOException
-
visitFile
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException
- Specified by:
visitFile
in interfaceFileVisitor<Path>
- Overrides:
visitFile
in classSimpleFileVisitor<Path>
- Throws:
IOException
-
-