List of utility methods to do Delete Directory Recursively
void | deleteDirectoryRecursive(File directory) delete Directory Recursive synchronized (EXMUT) { if (!directory.exists()) { return; if (!directory.isDirectory()) { throw new IllegalArgumentException("The passed file is not a directory (" + directory + ")."); if (!directory.exists()) { ... |
void | deleteDirectoryRecursive(File f) Delete a directory and all of it's contents in a depth-first recursive manner. if (f.isDirectory()) { for (File c : f.listFiles()) { deleteDirectoryRecursive(c); delete(f); |
void | deleteDirectoryRecursively(File rootFile) Recursive function to delete Directory having content. File[] files = rootFile.listFiles(); if (files != null) { for (File file : files) { if (file.isFile()) { file.delete(); } else if (file.isDirectory()) { deleteDirectoryRecursively(file); rootFile.delete(); |
void | deleteDirectoryRecursively(File toDelete) Delete file or empty and nonempty directory. if (toDelete != null) { if (toDelete.isDirectory()) { File[] sub = toDelete.listFiles(); if (sub != null && sub.length > 0) { for (File f : sub) { deleteDirectoryRecursively(f); toDelete.delete(); |
void | deleteDirectoryRecursivelyE(File dir) delete Directory Recursively E if (!dir.isDirectory()) throw new RuntimeException("Not a directory: " + dir.getAbsolutePath()); for (File f : dir.listFiles()) { if (f.isDirectory()) { deleteDirectoryRecursivelyE(f); } else { if (!f.delete()) throw new RuntimeException("Failed to delete file: " + f.getAbsolutePath()); ... |
boolean | deleteDirectoryRecursivly(File directory) delete Directory Recursivly String[] list = directory.list(); if (list != null) { for (String entryName : list) { File entry = new File(directory, entryName); if (entry.isDirectory()) { if (!deleteDirectoryRecursivly(entry)) { return false; } else { if (!entry.delete()) { return false; if (!directory.delete()) { return false; return true; |
void | deleteDirRecursive(File aDir) delete Dir Recursive if (!aDir.exists()) return; if (aDir.isDirectory()) { File[] files = aDir.listFiles(); for (int i = 0; i < files.length; i++) { deleteDirRecursive(files[i]); aDir.delete(); |
boolean | deleteDirRecursively(File dir) Given a filepath, delete all files in the directory recursively if (dir.isDirectory()) { for (File f : dir.listFiles()) { boolean success = deleteDirRecursively(f); if (!success) return false; return dir.delete(); ... |
boolean | deleteDirRecursively(File directory) This method deletes the directory, all files and all subdirectories under it. String dirName = ""; boolean success = true; if (directory.exists()) { if (directory.isDirectory()) { dirName = directory.getName(); File[] children = directory.listFiles(); for (File element : children) { if (element.isFile()) { ... |