Java Utililty Methods File Path Delete

List of utility methods to do File Path Delete

Description

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

Method

booleandeleteDir(File dir)
delete Dir
return deleteDir(dir, true, null);
voiddeleteDir(File dir)
Deletes the specified directory and any files it and directories contains.
for (String filename : dir.list()) {
    File file = new File(dir.getAbsolutePath() + "/" + filename);
    if (file.isDirectory()) {
        deleteDir(file);
    } else {
        file.delete();
dir.delete();
booleandeleteDir(File dir)
Deletes all files and subdirectories under dir and dir itself.
boolean empty = emptyDir(dir);
if (!empty) {
    return false;
return dir.delete();
booleandeleteDir(File dir)
delete Dir
if (dir.isDirectory()) {
    String[] children = dir.list();
    for (String child : children) {
        boolean success = deleteDir(new File(dir, child));
        if (!success) {
            return false;
return dir.delete();
booleandeleteDir(File dir)
Recursively deletes a directory.
if (dir.isDirectory()) {
    String[] children = dir.list();
    for (int i = 0; i < children.length; i++) {
        boolean success = deleteDir(new File(dir, children[i]));
        if (!success) {
            return false;
boolean isDeleted = dir.delete();
if (!isDeleted && dir.exists()) {
    System.gc();
    try {
        Thread.sleep(100);
    } catch (InterruptedException e) {
    isDeleted = dir.delete();
return isDeleted;
booleandeleteDir(File dir)
Deletes all files and sub directories under a directory.
if (dir.isDirectory()) {
    String[] children = dir.list();
    for (int i = 0; i < children.length; i++) {
        boolean success = deleteDir(new File(dir, children[i]));
        if (!success) {
            return false;
return dir.delete();
booleandeleteDir(File dir)
Deletes all files and subdirectories under "dir".
if (dir.isDirectory()) {
    String[] children = dir.list();
    for (int i = 0; i < children.length; i++) {
        deleteDir(new File(dir, children[i]));
return dir.delete();
voiddeleteDir(File dir)
Delete a directory and all of its contents.
if (!dir.exists()) {
    return;
File[] files = listFiles(dir);
for (int i = 0; i < files.length; i++) {
    File file = files[i];
    if (file.isDirectory()) {
        deleteDir(file);
...
booleandeleteDir(File dir)
Deletes all files and subdirectories under dir.
if (dir.isDirectory()) {
    String[] children = dir.list();
    for (int i = 0; i < children.length; i++) {
        boolean success = deleteDir(new File(dir, children[i]));
        if (!success) {
            return false;
return dir.delete();
voiddeleteDir(File dir)
Recursively deletes the specified directory.
if (!dir.exists())
    return;
if (!dir.isDirectory())
    throw new IllegalArgumentException("Not a directory: " + dir);
for (File file : dir.listFiles()) {
    if (file.isDirectory())
        deleteDir(file);
    else
...