public class FileSystemUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
copyDirectoryRecursively(File
Copy recursively a dir to a new location
|
static boolean |
deleteRecursively(File
Deletes the given files recursively including the given roots.
|
static boolean |
deleteRecursively(File
Deletes the given files recursively.
|
static boolean |
deleteRecursively(File
Delete the supplied
File - for directories, recursively delete any nested directories or files as well.
|
static void |
deleteSubDirectories(Path
Deletes all subdirectories in the given path recursively
|
static boolean |
exists(File
Returns true if at least one of the files exists.
|
static boolean |
exists(Path
Returns
true iff one of the files exists otherwise
false
|
static Path |
files(Path
Returns an array of all files in the given directory.
|
static boolean |
hasExtensions(File
|
static boolean |
isAccessibleDirectory(File
Check that a directory exists, is a directory and is readable by the current user
|
static boolean |
mkdirs(File
|
static void |
move(Path
Move or rename a file to a target file.
|
static void |
moveFilesWithoutOverwriting(File
This utility copy a full directory content (excluded) under a new directory but without overwriting existing files.
|
public static boolean mkdirs(Filedir)
public static boolean exists(File... files)
public static boolean exists(Path... files)
true iff one of the files exists otherwise
false
public 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 directory
IOException
public static boolean deleteRecursively(File... roots)
public static boolean deleteRecursively(Fileroot, boolean deleteRoot)
File - for directories, recursively delete any nested directories or files as well.
root - the root
File to delete
deleteRoot - whether or not to delete the root itself or just the content of the root.
true if the
File was deleted, otherwise
false
public static boolean isAccessibleDirectory(Filedirectory, ESLogger logger)
public static void moveFilesWithoutOverwriting(Filesource, 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 ignored
IOException
public static void copyDirectoryRecursively(Filesource, File destination) throws IOException
source - source dir
destination - destination dir
IOException
public static void move(Pathsource, Path destination) throws IOException
source - source file
destination - destination file
IOException
public static Path[] files(Path directory) throws IOException
IOException