public static void deleteAll(File dir, boolean deleteDirs) { if (dir == null) { return; } File[] children = dir.listFiles(); if (children != null) { for (int i = 0; i < children.length; i++) { File child = children[i]; deleteAll(child, deleteDirs); } } if (dir.isDirectory() && !deleteDirs) { return; } dir.delete();
public static void deleteAll(File dir) { deleteAll(dir, true);
    public static void deleteAll(File dir, boolean deleteDirs) {        if (dir == null) {            return;        }        File[] children = dir.listFiles();        if (children != null) {            for (int i = 0; i < children.length; i++) {                File child = children[i];                deleteAll(child, deleteDirs);            }        }        if (dir.isDirectory() && !deleteDirs) {            return;        }        dir.delete();    }