Facilities are provided in the following areas:
Note that a specific charset should be specified whenever possible. Relying on the platform default means that the code is Locale-dependent. Only use the default if the files are known to always use the platform default.
Origin of code: Excalibur, Alexandria, Commons-Utils
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static void | |
| private static void | cleanDirectoryOnExit(final File
directory to clean, must not be directory)nullCleans a directory without deleting it. |
| public static void | |
| private static void | deleteDirectoryOnExit(final File
directory to delete, must not be directory)nullSchedules a directory recursively for deletion on JVM exit. |
| public static void | |
| public static void | forceDeleteOnExit(final File
file or directory to delete, must not be file)nullSchedules a file to be deleted when JVM exits. |
| public static void | forceMkdir(final File
directory to create, must not be directory)nullMakes a directory, including any necessary but nonexistent parent directories. |
| public static void | forceMkdirParent(final File
file with parent to create, must not be file)nullMakes any necessary but nonexistent parent directories for a given File. |
| public static boolean |
| FileUtils | back to summary |
|---|---|
| public FileUtils() Instances should NOT be constructed in standard programming. | |
| cleanDirectory | back to summary |
|---|---|
| public static void cleanDirectory(final File directory) throws IOException Cleans a directory without deleting it.
| |
| cleanDirectoryOnExit | back to summary |
|---|---|
| private static void cleanDirectoryOnExit(final File directory) throws IOException Cleans a directory without deleting it.
| |
| deleteDirectory | back to summary |
|---|---|
| public static void deleteDirectory(final File directory) throws IOException Deletes a directory recursively.
| |
| deleteDirectoryOnExit | back to summary |
|---|---|
| private static void deleteDirectoryOnExit(final File directory) throws IOException Schedules a directory recursively for deletion on JVM exit.
| |
| forceDelete | back to summary |
|---|---|
| public static void forceDelete(final File file) throws IOException Deletes a file. If file is a directory, delete it and all sub-directories. The difference between File.delete() and this method are:
| |
| forceDeleteOnExit | back to summary |
|---|---|
| public static void forceDeleteOnExit(final File file) throws IOException Schedules a file to be deleted when JVM exits. If file is directory delete it and all sub-directories.
| |
| forceMkdir | back to summary |
|---|---|
| public static void forceMkdir(final File directory) throws IOException Makes a directory, including any necessary but nonexistent parent directories. If a file already exists with specified name but it is not a directory then an IOException is thrown. If the directory cannot be created (or does not already exist) then an IOException is thrown.
| |
| forceMkdirParent | back to summary |
|---|---|
| public static void forceMkdirParent(final File file) throws IOException Makes any necessary but nonexistent parent directories for a given File. If the parent directory cannot be created then an IOException is thrown.
| |
| isSymlink | back to summary |
|---|---|
| public static boolean isSymlink(File file) throws IOException Determines whether the specified file is a Symbolic Link rather than an actual file. 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
| |