List of utility methods to do Recursive Delete
void | recursivelyDeleteEmptyParentDirectoriesUpToRoot(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; |
boolean | recursivelyDeleteFile(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 { ... |
void | recursiveRemoveDir(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 { ... |
void | recursiveRemoveDir(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()) { ... |