public class FileUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
copyDirectory(File srcDir,
File destDir) |
static void |
copyFile(File srcFile,
File destFile,
boolean preserveFileDate)
Copied from the apache commons io project
|
static void |
deleteDirectory(File directory)
Copied from the apache commons io project.
|
public static void deleteDirectory(File directory) throws IOException
Deletes a directory recursively.
directory - - directory to deleteIOException - in case deletion is unsuccessfulIllegalArgumentException - if directory does not exist or is not a directorypublic static void copyFile(File srcFile, File destFile, boolean preserveFileDate) throws IOException
Internal copy file method. This caches the original file length, and an IOException will be thrown if the output file length is different from the current input file length. So it may fail if the file changes size. It may also fail with "IllegalArgumentException: Negative size" if the input file is truncated part way through copying the data and the new file size is less than the current position.
srcFile - - the validated source file, may not be nulldestFile - - the validated destination file, may 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
IOExceptionCopyright © 2023. All rights reserved.