Java Recursive Delete recursiveDelete(final File path)

Here you can find the source of recursiveDelete(final File path)

Description

Recursively delete the given path, stopping on the first error.

License

Apache License

Declaration

public static boolean recursiveDelete(final File path) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

public class Main {
    /**// w ww . jav a 2 s  .  c om
     * Recursively delete the given path, stopping on the first error.
     */
    public static boolean recursiveDelete(final File path) {
        if (path.isDirectory()) {
            String[] children = path.list();
            if (children == null) {
                return false;
            }
            for (int i = 0; i < children.length; i++) {
                if (!recursiveDelete(new File(path, children[i]))) {
                    return false;
                }
            }
        }
        return path.delete();
    }
}

Related

  1. recursiveDelete(File rootDir, boolean deleteRoot)
  2. recursiveDelete(File target)
  3. recursiveDelete(final File directory)
  4. recursiveDelete(final File file, final boolean childrenOnly)
  5. recursiveDelete(final File fileOrDir)
  6. recursiveDelete(final File path, final boolean deleteParent)
  7. recursiveDelete(final File pFile)
  8. recursiveDelete(final File root, final File file)
  9. recursiveDelete(String fileName)