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

voidrecursivelyDeleteEmptyParentDirectoriesUpToRoot(String path, String root)
recursively Delete Empty Parent Directories Up To Root
File dir = new File(path);
while (!root.equals(dir.getPath().replace('\\', '/'))) {
    if (dir.isDirectory()) {
        String[] files = dir.list();
        if (files != null && files.length == 0) {
            dir.delete();
    dir = dir.getParentFile();
    if (dir == null)
        break;
booleanrecursivelyDeleteFile(File path)
recursively Delete File
if (path.exists()) {
    if (path.isDirectory()) {
        File[] files = path.listFiles();
        if (files != null) {
            for (int i = 0; i < files.length; i++) {
                if (files[i].isDirectory()) {
                    recursivelyDeleteFile(files[i]);
                } else {
...
voidrecursiveRemoveDir(File dir)
recursive Remove Dir
if (dir == null || !dir.exists()) {
    return;
File[] files = dir.listFiles();
for (int i = 0; i < files.length; i++) {
    if (files[i].isDirectory()) {
        recursiveRemoveDir(files[i]);
    } else {
...
voidrecursiveRemoveDir(File directory)
del a directory recursively,that means delete all files and directorys.
if (!directory.exists()) {
    throw new IOException(directory.toString() + " do not exist!");
String[] filelist = directory.list();
File tmpFile = null;
for (int i = 0; i < filelist.length; i++) {
    tmpFile = new File(directory.getAbsolutePath(), filelist[i]);
    if (tmpFile.isDirectory()) {
...