Package org.spongepowered.api.util.file
Class CopyFileVisitor
- java.lang.Object
-
- java.nio.file.SimpleFileVisitor<java.nio.file.Path>
-
- org.spongepowered.api.util.file.CopyFileVisitor
-
- All Implemented Interfaces:
java.nio.file.FileVisitor<java.nio.file.Path>
public final class CopyFileVisitor extends java.nio.file.SimpleFileVisitor<java.nio.file.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(java.nio.file.Path target, java.nio.file.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 java.nio.file.FileVisitResult
preVisitDirectory(java.nio.file.Path dir, java.nio.file.attribute.BasicFileAttributes attrs)
java.nio.file.FileVisitResult
visitFile(java.nio.file.Path file, java.nio.file.attribute.BasicFileAttributes attrs)
-
-
-
Constructor Detail
-
CopyFileVisitor
public CopyFileVisitor(java.nio.file.Path target, java.nio.file.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 java.nio.file.FileVisitResult preVisitDirectory(java.nio.file.Path dir, java.nio.file.attribute.BasicFileAttributes attrs) throws java.io.IOException
- Specified by:
preVisitDirectory
in interfacejava.nio.file.FileVisitor<java.nio.file.Path>
- Overrides:
preVisitDirectory
in classjava.nio.file.SimpleFileVisitor<java.nio.file.Path>
- Throws:
java.io.IOException
-
visitFile
public java.nio.file.FileVisitResult visitFile(java.nio.file.Path file, java.nio.file.attribute.BasicFileAttributes attrs) throws java.io.IOException
- Specified by:
visitFile
in interfacejava.nio.file.FileVisitor<java.nio.file.Path>
- Overrides:
visitFile
in classjava.nio.file.SimpleFileVisitor<java.nio.file.Path>
- Throws:
java.io.IOException
-
-