List of utility methods to do Directory Remove Recursive
void | deltree(File directory) deltree if (directory.exists() && directory.isDirectory()) { File[] fileArray = directory.listFiles(); for (int i = 0; i < fileArray.length; i++) { if (fileArray[i].isDirectory()) { deltree(fileArray[i]); } else { fileArray[i].delete(); directory.delete(); |
void | deltree(String directory) deltree deltree(new File(directory));
|
void | recursiveRemoveDir(File directory) This class 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()) { recursiveRemoveDir(tmpFile); ... |
boolean | removeDirectories(File file) recursively remove directory and all sub directories if (!file.exists()) return true; if (file.isDirectory()) { File[] subFiles = file.listFiles(); for (File subFile : subFiles) { if (!removeDirectories(subFile)) return false; return file.delete(); |
boolean | removeDirectories(File file, String regex) recursively remove directory and all sub directories which matches regular expression if (!file.exists()) return true; if (file.isDirectory()) { if (file.getName().matches(regex)) { if (!removeDirectories(file)) return false; } else { File[] subFiles = file.listFiles(); ... |
Boolean | delete(String root) Delete File or Folder recursively if (root == null) { return false; File f = new File(root); if (f.isDirectory()) { for (File tmp : f.listFiles()) { delete(tmp.getAbsolutePath()); return f.delete(); |
void | DeleteRecursive(File fileOrDirectory) Elimina um ficheiro ou diretoria recursivamente. if (fileOrDirectory.isDirectory()) for (File child : fileOrDirectory.listFiles()) DeleteRecursive(child); try { fileOrDirectory.delete(); } catch (Exception e) { |