Java Utililty Methods Delete Directory

List of utility methods to do Delete Directory

Description

The list of methods to do Delete Directory are organized into topic(s).

Method

booleandeleteDirectory(File directory)
delete Directory
return deleteDirectory(directory, false);
voiddeleteDirectory(File directory)
Deletes a directory recursively.
if (!directory.exists()) {
    return;
if (!isSymlink(directory)) {
    cleanDirectory(directory);
if (!directory.delete()) {
    String message = "Unable to delete directory " + directory + ".";
...
voiddeleteDirectory(File directory)
delete Directory
if (!directory.exists())
    return;
if (!isSymlink(directory))
    cleanDirectory(directory);
if (!directory.delete()) {
    String message = "Unable to delete directory " + directory + ".";
    throw new IOException(message);
voiddeleteDirectory(File directory)
delete Directory
if (directory != null) {
    deleteInDirectory(directory);
    directory.delete();
booleandeleteDirectory(File directory)
Delete directory.
try {
    if (directory.isDirectory()) {
        File[] files = directory.listFiles();
        for (int i = 0; i < files.length; i++) {
            File file = files[i];
            if (file.isFile()) {
                boolean deletion = file.delete();
                if (!deletion)
...
voiddeleteDirectory(File directory)
Deletes a directory recursively.
if (!directory.exists()) {
    return;
if (!directory.delete()) {
    String message = "Unable to delete directory " + directory + ".";
    throw new IOException(message);
voiddeleteDirectory(File directory)
delete Directory
if (!directory.exists()) {
    return;
if (directory.isFile()) {
    directory.delete();
    return;
for (File file : directory.listFiles()) {
...
voiddeleteDirectory(File directory)
delete Directory
if (!directory.exists()) {
    return;
if (!isSymlink(directory)) {
    cleanDirectory(directory);
if (!directory.delete()) {
    String message = "Unable to delete directory " + directory + ".";
...
voiddeleteDirectory(File directory)
delete Directory
if (!directory.exists()) {
    return;
forceDelete(directory);
if (!directory.delete()) {
    throw new IOException("Unable to delete directory " + directory + ".");
voiddeleteDirectory(File directory)
Delete all the files in a directory and then delete the directory itself.
File[] firstDirectoryFiles = directory.listFiles();
if (firstDirectoryFiles != null) {
    for (File file : firstDirectoryFiles) {
        file.delete();
directory.delete();