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
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++) {
        boolean success = deleteDir(new File(dir, children[i]));
        if (!success) {
            return false;
return dir.delete();
voiddeleteDir(File dir)
delete Dir
String[] entries = dir.list();
if (entries != null) {
    for (String name : entries) {
        File file = new File(dir.getPath(), name);
        file.delete();
dir.delete();
...
voiddeleteDir(File dir)
delete Dir
String[] children = dir.list();
for (String child : children) {
    File file = new File(dir, child);
    if (file.isFile()) {
        deleteFile(file);
    } else {
        deleteDir(file);
deleteFile(dir);
booleandeleteDir(File dir)
Recursively delete a directory and all its contents.
if (!dir.isDirectory()) {
    throw new IllegalArgumentException(dir + " does not exist or is not a directory");
File[] contents = dir.listFiles();
for (File file : contents) {
    if (file.isDirectory()) {
        deleteDir(file);
    } else {
...
booleandeleteDir(File dir)
Delete the specified directory.
if (dir == null)
    return true;
if (!dir.exists())
    return true;
File files[] = dir.listFiles();
for (File file : files) {
    if (file.isDirectory()) {
        if (!deleteDir(file))
...
voiddeleteDir(File dir)
Deletes the specified diretory and any files and directories in it recursively.
if (!dir.isDirectory()) {
    throw new IOException("Not a directory " + dir);
File[] files = dir.listFiles();
for (int i = 0; i < files.length; i++) {
    File file = files[i];
    if (file.isDirectory()) {
        deleteDir(file);
...
booleandeleteDir(File dir)
deletes all Files and Subfolders in a directory
if (dir.isDirectory()) {
    String[] entries = dir.list();
    for (int x = 0; x < entries.length; x++) {
        File aktFile = new File(dir.getPath(), entries[x]);
        deleteDir(aktFile);
    if (dir.delete()) {
        return true;
...
booleandeleteDir(File dir)
Helper function to (recursively) delete a directory and all its contents
if (!dir.exists()) {
    return true;
if (dir.isDirectory()) {
    String[] children = dir.list();
    for (String element : children) {
        boolean success = deleteDir(new File(dir, element));
        if (!success) {
...
booleandeleteDir(File dir)
delete Dir
if (null == dir || !dir.exists())
    return false;
if (!dir.isDirectory())
    throw new IOException("\"" + dir.getAbsolutePath() + "\" should be a directory!");
File[] files = dir.listFiles();
boolean re = false;
if (null != files) {
    if (files.length == 0)
...