List of utility methods to do Delete File Recursively
boolean | deleteRecursively(File file) delete Recursively boolean success = true; if (file.isDirectory()) { for (File f : file.listFiles()) { if (f.isDirectory()) { success = success && deleteRecursively(f); success = success && f.delete(); success = success && file.delete(); return success; |
void | deleteRecursively(File fileEntry) Recursively deletes a directory or a file immediately. if (fileEntry.isDirectory()) { File[] listFiles = fileEntry.listFiles(); for (File file : listFiles) { deleteRecursively(file); if (!fileEntry.delete()) { fileEntry.deleteOnExit(); ... |
void | deleteRecursively(File fileOrDir) delete Recursively if (fileOrDir.isFile()) { deleteFile(fileOrDir); } else if (fileOrDir.isDirectory()) { String[] names = fileOrDir.list(); if (names != null) { for (String name : names) { deleteRecursively(new File(fileOrDir, name)); if (!fileOrDir.delete()) { throw new IOException("Could not delete dir: " + fileOrDir); } else { throw new IOException("Neither file nor dir: " + fileOrDir); |
void | deleteRecursively(File fileOrDir) delete Recursively if (fileOrDir.isDirectory()) for (File f : fileOrDir.listFiles()) deleteRecursively(f); fileOrDir.delete(); |
boolean | deleteRecursively(File fileToDelete) Delete a directory recursively boolean retval = true; if (fileToDelete.isDirectory()) { for (File fileInDir : fileToDelete.listFiles()) { retval &= deleteRecursively(fileInDir); retval &= fileToDelete.delete(); return retval; ... |
void | deleteRecursively(File fRoot) Deletes all files and directories under the given directory. if (fRoot == null) { throw new NullPointerException("Root folder is null."); if (fRoot.isFile()) { if (!fRoot.delete()) { throw new IOException("Unable to delete file '" + fRoot.getAbsolutePath() + "'"); return; ... |
void | deleteRecursively(File name) delete Recursively if (name.isDirectory()) { File[] subdirs = name.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { return pathname.isDirectory(); }); for (int i = 0; i < subdirs.length; ++i) { ... |
boolean | deleteRecursively(File root) Delete the supplied File - for directories, recursively delete any nested directories or files as well. if (root != null && root.exists()) { if (root.isDirectory()) { File[] children = root.listFiles(); if (children != null) { for (int i = 0; i < children.length; i++) { deleteRecursively(children[i]); return root.delete(); return false; |
boolean | deleteRecursively(File root) Delete the supplied File - for directories, recursively delete any nested directories or files as well. if (root.exists()) { if (root.isDirectory()) { File[] children = root.listFiles(); for (int i = 0; i < children.length; i++) { deleteRecursively(children[i]); return root.delete(); ... |
boolean | deleteRecursively(File root, boolean deleteRoot) Delete the supplied java.io.File - for directories, recursively delete any nested directories or files as well. if (root != null && root.exists()) { if (root.isDirectory()) { File[] children = root.listFiles(); if (children != null) { for (File aChildren : children) { deleteRecursively(aChildren); if (deleteRoot) { return root.delete(); } else { return true; return false; |