| Modifier and Type | Field and Description |
|---|---|
static FileVisitOption[] |
EMPTY_FILE_VISIT_OPTION_ARRAY
Empty
FileVisitOption array. |
static LinkOption[] |
EMPTY_LINK_OPTION_ARRAY
Empty
LinkOption array. |
static OpenOption[] |
EMPTY_OPEN_OPTION_ARRAY
Empty
OpenOption array. |
| Modifier and Type | Method and Description |
|---|---|
static Counters.PathCounters |
cleanDirectory(Path directory)
Cleans a directory including sub-directories without deleting directories.
|
static Counters.PathCounters |
copyDirectory(Path sourceDirectory,
Path targetDirectory,
CopyOption... copyOptions)
Copies a directory to another directory.
|
static Path |
copyFile(URL sourceFile,
Path targetFile,
CopyOption... copyOptions)
Copies a URL to a directory.
|
static Path |
copyFileToDirectory(Path sourceFile,
Path targetDirectory,
CopyOption... copyOptions)
Copies a file to a directory.
|
static Path |
copyFileToDirectory(URL sourceFile,
Path targetDirectory,
CopyOption... copyOptions)
Copies a URL to a directory.
|
static Counters.PathCounters |
countDirectory(Path directory)
Counts aspects of a directory including sub-directories.
|
static Counters.PathCounters |
delete(Path path)
Deletes a file or directory.
|
static Counters.PathCounters |
deleteDirectory(Path directory)
Deletes a directory including sub-directories.
|
static Counters.PathCounters |
deleteFile(Path file)
Deletes the given file.
|
static boolean |
directoryAndFileContentEquals(Path path1,
Path path2)
Compares the file sets of two Paths to determine if they are equal or not while considering file contents.
|
static boolean |
directoryAndFileContentEquals(Path path1,
Path path2,
LinkOption[] linkOptions,
OpenOption[] openOptions,
FileVisitOption[] fileVisitOption)
Compares the file sets of two Paths to determine if they are equal or not while considering file contents.
|
static boolean |
directoryContentEquals(Path path1,
Path path2)
Compares the file sets of two Paths to determine if they are equal or not without considering file contents.
|
static boolean |
directoryContentEquals(Path path1,
Path path2,
int maxDepth,
LinkOption[] linkOptions,
FileVisitOption[] fileVisitOptions)
Compares the file sets of two Paths to determine if they are equal or not without considering file contents.
|
static boolean |
fileContentEquals(Path path1,
Path path2)
Compares the file contents of two Paths to determine if they are equal or not.
|
static boolean |
fileContentEquals(Path path1,
Path path2,
LinkOption[] linkOptions,
OpenOption[] openOptions)
Compares the file contents of two Paths to determine if they are equal or not.
|
static boolean |
isEmpty(Path path)
Returns whether the given file or directory is empty.
|
static boolean |
isEmptyDirectory(Path directory)
Returns whether the directory is empty.
|
static boolean |
isEmptyFile(Path file)
Returns whether the given file is empty.
|
static <T extends FileVisitor<? super Path>> |
visitFileTree(T visitor,
Path directory)
Performs
Files.walkFileTree(Path,FileVisitor) and returns the given visitor. |
static <T extends FileVisitor<? super Path>> |
visitFileTree(T visitor,
Path start,
Set<FileVisitOption> options,
int maxDepth)
Performs
Files.walkFileTree(Path,FileVisitor) and returns the given visitor. |
static <T extends FileVisitor<? super Path>> |
visitFileTree(T visitor,
String first,
String... more)
Performs
Files.walkFileTree(Path,FileVisitor) and returns the given visitor. |
static <T extends FileVisitor<? super Path>> |
visitFileTree(T visitor,
URI uri)
Performs
Files.walkFileTree(Path,FileVisitor) and returns the given visitor. |
public static final FileVisitOption[] EMPTY_FILE_VISIT_OPTION_ARRAY
FileVisitOption array.public static final LinkOption[] EMPTY_LINK_OPTION_ARRAY
LinkOption array.public static final OpenOption[] EMPTY_OPEN_OPTION_ARRAY
OpenOption array.public static Counters.PathCounters cleanDirectory(Path directory) throws IOException
directory - directory to clean.IOException - if an I/O error is thrown by a visitor method.public static Counters.PathCounters copyDirectory(Path sourceDirectory, Path targetDirectory, CopyOption... copyOptions) throws IOException
sourceDirectory - The source directory.targetDirectory - The target directory.copyOptions - Specifies how the copying should be done.IOException - if an I/O error is thrown by a visitor method.public static Path copyFile(URL sourceFile, Path targetFile, CopyOption... copyOptions) throws IOException
sourceFile - The source URL.targetFile - The target file.copyOptions - Specifies how the copying should be done.IOException - if an I/O error occursFiles.copy(InputStream, Path, CopyOption...)public static Path copyFileToDirectory(Path sourceFile, Path targetDirectory, CopyOption... copyOptions) throws IOException
sourceFile - The source file.targetDirectory - The target directory.copyOptions - Specifies how the copying should be done.IOException - if an I/O error occursFiles.copy(Path, Path, CopyOption...)public static Path copyFileToDirectory(URL sourceFile, Path targetDirectory, CopyOption... copyOptions) throws IOException
sourceFile - The source URL.targetDirectory - The target directory.copyOptions - Specifies how the copying should be done.IOException - if an I/O error occursFiles.copy(InputStream, Path, CopyOption...)public static Counters.PathCounters countDirectory(Path directory) throws IOException
directory - directory to delete.IOException - if an I/O error is thrown by a visitor method.public static Counters.PathCounters delete(Path path) throws IOException
The difference between File.delete() and this method are:
File.delete() returns a
boolean.
path - file or directory to delete, must not be nullNullPointerException - if the directory is nullIOException - if an I/O error is thrown by a visitor method or if an I/O error occurs.public static Counters.PathCounters deleteDirectory(Path directory) throws IOException
directory - directory to delete.IOException - if an I/O error is thrown by a visitor method.public static Counters.PathCounters deleteFile(Path file) throws IOException
file - The file to delete.IOException - if an I/O error occurs.NotDirectoryException - if the file is a directory.public static boolean directoryAndFileContentEquals(Path path1, Path path2) throws IOException
path1 - The first directory.path2 - The second directory.IOException - if an I/O error is thrown by a visitor methodpublic static boolean directoryAndFileContentEquals(Path path1, Path path2, LinkOption[] linkOptions, OpenOption[] openOptions, FileVisitOption[] fileVisitOption) throws IOException
path1 - The first directory.path2 - The second directory.linkOptions - options to follow links.openOptions - options to open files.fileVisitOption - options to configure traversal.IOException - if an I/O error is thrown by a visitor methodpublic static boolean directoryContentEquals(Path path1, Path path2) throws IOException
path1 - The first directory.path2 - The second directory.IOException - if an I/O error is thrown by a visitor methodpublic static boolean directoryContentEquals(Path path1, Path path2, int maxDepth, LinkOption[] linkOptions, FileVisitOption[] fileVisitOptions) throws IOException
path1 - The first directory.path2 - The second directory.maxDepth - See Files.walkFileTree(Path,Set,int,FileVisitor).linkOptions - options to follow links.fileVisitOptions - options to configure the traversalIOException - if an I/O error is thrown by a visitor methodpublic static boolean fileContentEquals(Path path1, Path path2) throws IOException
File content is accessed through Files.newInputStream(Path,OpenOption...).
path1 - the first stream.path2 - the second stream.NullPointerException - if either input is null.IOException - if an I/O error occurs.FileUtils.contentEquals(java.io.File, java.io.File)public static boolean fileContentEquals(Path path1, Path path2, LinkOption[] linkOptions, OpenOption[] openOptions) throws IOException
File content is accessed through Files.newInputStream(Path,OpenOption...).
path1 - the first stream.path2 - the second stream.linkOptions - options specifying how files are followed.openOptions - options specifying how files are opened.NullPointerException - if either input is null.IOException - if an I/O error occurs.FileUtils.contentEquals(java.io.File, java.io.File)public static boolean isEmpty(Path path) throws IOException
path - the the given file or directory to query.IOException - if an I/O error occurspublic static boolean isEmptyDirectory(Path directory) throws IOException
directory - the the given directory to query.IOException - if an I/O error occurspublic static boolean isEmptyFile(Path file) throws IOException
file - the the given file to query.IOException - if an I/O error occurspublic static <T extends FileVisitor<? super Path>> T visitFileTree(T visitor, Path directory) throws IOException
Files.walkFileTree(Path,FileVisitor) and returns the given visitor.
Note that Files.walkFileTree(Path,FileVisitor) returns the given path.T - See Files.walkFileTree(Path,FileVisitor).visitor - See Files.walkFileTree(Path,FileVisitor).directory - See Files.walkFileTree(Path,FileVisitor).IOException - if an I/O error is thrown by a visitor methodpublic static <T extends FileVisitor<? super Path>> T visitFileTree(T visitor, Path start, Set<FileVisitOption> options, int maxDepth) throws IOException
Files.walkFileTree(Path,FileVisitor) and returns the given visitor.
Note that Files.walkFileTree(Path,FileVisitor) returns the given path.T - See Files.walkFileTree(Path,Set,int,FileVisitor).start - See Files.walkFileTree(Path,Set,int,FileVisitor).options - See Files.walkFileTree(Path,Set,int,FileVisitor).maxDepth - See Files.walkFileTree(Path,Set,int,FileVisitor).visitor - See Files.walkFileTree(Path,Set,int,FileVisitor).IOException - if an I/O error is thrown by a visitor methodpublic static <T extends FileVisitor<? super Path>> T visitFileTree(T visitor, String first, String... more) throws IOException
Files.walkFileTree(Path,FileVisitor) and returns the given visitor.
Note that Files.walkFileTree(Path,FileVisitor) returns the given path.T - See Files.walkFileTree(Path,FileVisitor).visitor - See Files.walkFileTree(Path,FileVisitor).first - See Paths.get(String,String[]).more - See Paths.get(String,String[]).IOException - if an I/O error is thrown by a visitor methodpublic static <T extends FileVisitor<? super Path>> T visitFileTree(T visitor, URI uri) throws IOException
Files.walkFileTree(Path,FileVisitor) and returns the given visitor.
Note that Files.walkFileTree(Path,FileVisitor) returns the given path.T - See Files.walkFileTree(Path,FileVisitor).visitor - See Files.walkFileTree(Path,FileVisitor).uri - See Paths.get(URI).IOException - if an I/O error is thrown by a visitor methodCopyright © 2002–2020 The Apache Software Foundation. All rights reserved.