public class FileSystemUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
copyDirectoryRecursively(File source,
File destination)
Copy recursively a dir to a new location
|
static boolean |
deleteRecursively(File... roots)
Deletes the given files recursively including the given roots.
|
static boolean |
deleteRecursively(File[] roots,
boolean deleteRoots)
Deletes the given files recursively.
|
static boolean |
deleteRecursively(File root,
boolean deleteRoot)
Delete the supplied
File - for directories,
recursively delete any nested directories or files as well. |
static void |
deleteSubDirectories(Path... paths)
Deletes all subdirectories in the given path recursively
|
static boolean |
exists(File... files)
Returns true if at least one of the files exists.
|
static boolean |
exists(Path... files)
Returns
true iff one of the files exists otherwise false |
static Path[] |
files(Path directory)
Returns an array of all files in the given directory.
|
static boolean |
hasExtensions(File root,
String... extensions) |
static boolean |
isAccessibleDirectory(File directory,
ESLogger logger)
Check that a directory exists, is a directory and is readable
by the current user
|
static boolean |
mkdirs(File dir) |
static void |
move(Path source,
Path destination)
Move or rename a file to a target file.
|
static void |
moveFilesWithoutOverwriting(File source,
File destination,
String suffix)
This utility copy a full directory content (excluded) under
a new directory but without overwriting existing files.
|
public static boolean mkdirs(File dir)
public static boolean exists(File... files)
public static boolean exists(Path... files)
true iff one of the files exists otherwise falsepublic static boolean deleteRecursively(File[] roots, boolean deleteRoots)
true
the given root files will be deleted as well. Otherwise only their content is deleted.public static void deleteSubDirectories(Path... paths) throws IOException
IllegalArgumentException - if the given path is not a directoryIOExceptionpublic static boolean deleteRecursively(File... roots)
public static boolean deleteRecursively(File root, boolean deleteRoot)
File - for directories,
recursively delete any nested directories or files as well.root - the root File to deletedeleteRoot - whether or not to delete the root itself or just the content of the root.true if the File was deleted,
otherwise falsepublic static boolean isAccessibleDirectory(File directory, ESLogger logger)
public static void moveFilesWithoutOverwriting(File source, File destination, String suffix) throws IOException
source - Source directory (for example /tmp/es/src)destination - Destination directory (destination directory /tmp/es/dst)suffix - When not null, files are copied with a suffix appended to the original name (eg: ".new")
When null, files are ignoredIOExceptionpublic static void copyDirectoryRecursively(File source, File destination) throws IOException
source - source dirdestination - destination dirIOExceptionpublic static void move(Path source, Path destination) throws IOException
source - source filedestination - destination fileIOExceptionpublic static Path[] files(Path directory) throws IOException
IOExceptionCopyright © 2009–2016. All rights reserved.