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, boolean ignoreErrors)
delete Directory
try {
    if (directory.exists() && directory.isDirectory()) {
        File files[] = directory.listFiles();
        for (File file : files) {
            if (file.isDirectory()) {
                deleteDirectory(file, true);
            } else {
                file.delete();
...
voiddeleteDirectory(File f)
Borra todos los ficheros contenidos en un directorio.
File[] contents = f.listFiles();
for (int i = 0; i < contents.length; i++) {
    if (contents[i].isDirectory())
        deleteDirectory(contents[i]);
    contents[i].delete();
voiddeleteDirectory(File f)
Recursive delete method for deleting directories.
if (f.isDirectory()) {
    for (File c : f.listFiles())
        deleteDirectory(c);
if (!f.delete()) {
    throw new FileNotFoundException("Failed to delete file: " + f);
voiddeleteDirectory(File f)
delete Directory
if (f.isDirectory()) {
    for (File c : f.listFiles()) {
        deleteDirectory(c);
if (!f.delete())
    throw new FileNotFoundException("Failed to delete file: " + f);
booleandeleteDirectory(File f)
delete Directory
if (f.exists() && f.isDirectory()) {
    File[] files = f.listFiles();
    if (null != files) {
        for (int i = 0; i < files.length; i++) {
            if (files[i].isDirectory()) {
                deleteDirectory(files[i]);
            } else {
                files[i].delete();
...
voiddeleteDirectory(File file)
Delete a Directory.
if (file.isDirectory()) {
    if (file.list().length == 0) {
        file.setWritable(true);
        boolean b = file.delete();
        if (!b)
            throw new IOException(
                    "Directory cannot be deleted : " + file.getAbsolutePath() + "\nCheck permissions.");
    } else {
...
booleandeleteDirectory(File file)
delete Directory
if (file == null) {
    return false;
if (file.exists()) {
    for (final File f : file.listFiles()) {
        if (f.isDirectory()) {
            deleteDirectory(f);
            f.delete();
...
voiddeleteDirectory(File file)
delete Directory
if (!file.exists()) {
    return;
if (file.isDirectory()) {
    File[] fileList = file.listFiles();
    if (fileList != null) {
        for (File ff : fileList) {
            deleteDirectory(ff);
...
voiddeleteDirectory(File file)
Deletes the directory if the directory has no files.
if (file.isDirectory()) {
    if (file.list().length == 0) {
        file.delete();
    } else {
        String[] files = file.list();
        for (String temp : files) {
            File fileDelete = new File(file, temp);
            deleteDirectory(fileDelete);
...
voiddeleteDirectory(File file)
delete Directory
try {
    File[] files = file.listFiles();
    if (files != null)
        for (int i = 0; i < files.length; i++) {
            deleteDirectory(files[i]);
} catch (Exception e) {
try {
    file.delete();
} catch (Exception e) {