Java Utililty Methods Recursive Delete

List of utility methods to do Recursive Delete

Description

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

Method

voidrecursiveDelete(final File path, final boolean deleteParent)
recursive Delete
if (!path.exists()) {
    return;
for (final File file : path.listFiles()) {
    if (file.isDirectory()) {
        recursiveDelete(file, true);
    } else {
        file.delete();
...
booleanrecursiveDelete(final File pFile)
Deleting a storage recursive.
if (pFile.isDirectory()) {
    for (final File child : pFile.listFiles()) {
        if (!recursiveDelete(child)) {
            return false;
return pFile.delete();
...
voidrecursiveDelete(final File root, final File file)
recursive Delete
if (!file.isDirectory()) {
    file.delete();
} else {
    for (File next : file.listFiles()) {
        recursiveDelete(root, next);
    if (!file.equals(root)) {
        file.delete();
...
booleanrecursiveDelete(String fileName)
recursive Delete
File file = new File(fileName);
if (file.exists()) {
    if (file.isDirectory() && (file.list()).length > 0) {
        for (String s : file.list()) {
            recursiveDelete(fileName + System.getProperty("file.separator") + s);
    if (!file.setWritable(true)) {
...
booleanrecursiveDelete(String p_path, boolean p_deletemetoo)
Recursively delete a directory.
if (p_path == null) {
    return true;
String path = p_path;
if (path.endsWith("\\") || path.endsWith("/")) {
    path = path.substring(0, path.length() - 1);
File f = new File(path);
...
voidrecursiveDelete(String path)
Recursively deletes the given path (file or directory).
recursiveDelete(new File(path));
voidrecursiveDeleteFile(File f)
recursive Delete File
File[] children = f.listFiles();
if (children != null) {
    for (int i = 0; i < children.length; i++)
        recursiveDeleteFile(children[i]);
f.delete();
voidrecursiveDeleteFile(File file)
recursive Delete File
if (!file.exists()) {
    return;
if (file.isDirectory()) {
    Arrays.stream(file.listFiles()).forEach(a -> recursiveDeleteFile(a));
file.delete();
booleanrecursiveDeleteFile(File file)
recursive Delete File
if (file.isDirectory()) {
    File[] fileArray = file.listFiles();
    boolean returned = true;
    for (int i = 0; i < fileArray.length; i++) {
        File curFile = fileArray[i];
        if (recursiveDeleteFile(curFile) == false) {
            returned = false;
    return returned && file.delete();
} else {
    return file.delete();
voidrecursiveDeleteHelper(File parent, List failed)
recursive Delete Helper
if (parent.isDirectory()) {
    for (File child : parent.listFiles()) {
        recursiveDeleteHelper(child, failed);
if (!parent.delete())
    failed.add(parent);