public class FileUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
cleanDirectory(File directory)
Copied from the apache commons io project
Cleans a directory without deleting it.
|
static void |
closeQuietly(Closeable... closeables) |
static void |
copyDirectory(File srcDir,
File destDir) |
static void |
copyDirectory(File srcDir,
File destDir,
FileFilter filter,
boolean preserveFileDate,
List<String> exclusionList)
Copied from the apache commons io project
Internal copy directory method.
|
static void |
copyFile(File srcFile,
File destFile,
boolean preserveFileDate)
Copied from the apache commons io project
Internal copy file method.
|
static void |
deleteDirectory(File directory)
Copied from the apache commons io project
Deletes a directory recursively.
|
static void |
forceDelete(File file)
Copied from the apache commons io project
Deletes a file.
|
static boolean |
isSymlink(File file)
Copied from the apache commons io project
Determines whether the specified file is a Symbolic Link rather than an actual file.
|
public static void deleteDirectory(File directory) throws IOException
directory - - directory to deleteIOException - in case deletion is unsuccessfulIllegalArgumentException - if directory does not exist or is not a directorypublic static boolean isSymlink(File file) throws IOException
Will not return true if there is a Symbolic Link anywhere in the path, only if the specific file is.
Note: the current implementation always returns false if the system
is detected as Windows using Configuration.isWindows()
For code that runs on Java 1.7 or later, use the following method instead:
boolean java.nio.file.Files.isSymbolicLink(Path path)
file - - the file to checkIOException - if an IO error occurs while checking the filepublic static void cleanDirectory(File directory) throws IOException
directory - - directory to cleanIOException - in case cleaning is unsuccessfulIllegalArgumentException - if directory does not exist or is not a directorypublic static void forceDelete(File file) throws IOException
The difference between File.delete() and this method are:
file - - file or directory to delete, must not be nullNullPointerException - if the directory is nullFileNotFoundException - if the file was not foundIOException - in case deletion is unsuccessfulpublic static void copyFile(File srcFile, File destFile, boolean preserveFileDate) throws IOException
srcFile - - the validated source file, must not be nulldestFile - - the validated destination file, must not be nullpreserveFileDate - whether to preserve the file dateIOException - if an error occursIOException - if the output file length is not the same as the input
file length after the copy completesIllegalArgumentException - "Negative size" if the file is truncated so that the size
is less than the positionpublic static void copyDirectory(File srcDir, File destDir) throws IOException
IOExceptionpublic static void copyDirectory(File srcDir, File destDir, FileFilter filter, boolean preserveFileDate, List<String> exclusionList) throws IOException
srcDir - - the validated source directory, must not be nulldestDir - - the validated destination directory, must not be nullfilter - - the filter to apply, null means copy all directories and filespreserveFileDate - - whether to preserve the file dateexclusionList - - List of files and directories to exclude from the copy, may be nullIOException - if an error occurspublic static void closeQuietly(Closeable... closeables)
Copyright © 2017. All rights reserved.