Java Utililty Methods Directory Delete

List of utility methods to do Directory Delete

Description

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

Method

booleanemptyDir(File dir)
Delete the contents of a directory, leaving the empty directory.
String files[] = dir.list();
if (files == null) {
    return false; 
boolean ret = true;
for (int i = 0; i < files.length; i++) {
    File f = new File(dir, files[i]);
    if (f.isDirectory()) {
...
voidemptyDir(File dir)
empty Dir
if (!(dir.exists() && dir.canWrite())) {
    throw new IOException(
            "Kann Verzeichnis nicht leeren, es ist nicht vorhanden " + "oder nicht beschreibbar");
if (dir.isDirectory()) {
    String[] children = dir.list();
    for (int i = 0; i < children.length; i++) {
        File current = new File(dir, children[i]);
...
booleanemptyDir(File dir)
Deletes all files and subdirectories under dir.
if (dir.isDirectory()) {
    for (File child : dir.listFiles()) {
        boolean success = deleteDir(child);
        if (!success) {
            return false;
return true;
voidemptyDir(File dir)
empty Dir
if (dir.isDirectory()) {
    String[] files = dir.list();
    if (files != null) {
        for (int i = 0; i < files.length; i += 1) {
            new File(dir, files[i]).delete();
} else {
...
voidemptyDir(File dir)
empty Dir
File[] files = dir.listFiles();
for (int i = 0; i < files.length; i++) {
    if (files[i].isDirectory()) {
        emptyDir(files[i]);
    files[i].delete();
voidemptyDir(File directory)
empty Dir
if (directory.exists() && directory.isDirectory()) {
    File[] contents = directory.listFiles();
    for (File file : contents) {
        if (file.isDirectory()) {
            emptyDir(file);
            file.delete();
        } else {
            file.delete();
...
booleanemptyDir(String dirName)
empty Dir
boolean result = false;
File dir = new File(dirName);
if (dir != null && dir.isDirectory()) {
    File[] files = dir.listFiles();
    result = files.length == 0 ? true : false;
return result;
voidemptyDir(String path)
empty Dir
File dir = new File(path);
assert dir.isDirectory();
for (File file : dir.listFiles()) {
    delete(file);
voidemptyDirectory(File dir)
empty Directory
for (File f : dir.listFiles()) {
    f.delete();
voidemptyDirectory(File dir)
empty Directory
File[] files = dir.listFiles();
if (files == null) {
    return;
int len = files.length;
for (int i = 0; i < len; i++) {
    File file = files[i];
    if (file.isDirectory()) {
...