public class FileUtils extends Object
Facilities are provided in the following areas:
Origin of code: Excalibur, Alexandria, Commons-Utils
Constructor and Description |
---|
FileUtils()
Instances should NOT be constructed in standard programming.
|
Modifier and Type | Method and Description |
---|---|
static void |
cleanDirectory(File directory)
Cleans a directory without deleting it.
|
static void |
deleteDirectory(File directory)
Deletes a directory recursively.
|
static void |
forceDelete(File file)
Deletes a file.
|
static void |
forceDeleteOnExit(File file)
Schedules a file to be deleted when JVM exits.
|
public FileUtils()
public static void deleteDirectory(File directory) throws IOException
directory
- directory to deleteIOException
- in case deletion is unsuccessfulpublic static void cleanDirectory(File directory) throws IOException
directory
- directory to cleanIOException
- in case cleaning is unsuccessfulpublic 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 null
NullPointerException
- if the directory is null
FileNotFoundException
- if the file was not foundIOException
- in case deletion is unsuccessfulpublic static void forceDeleteOnExit(File file) throws IOException
file
- file or directory to delete, must not be null
NullPointerException
- if the file is null
IOException
- in case deletion is unsuccessfulCopyright © 2014 JBoss by Red Hat. All Rights Reserved.