List of utility methods to do Directory Delete
boolean | deleteDirectory(File path) delete Directory if (path.exists()) { File[] files = path.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { deleteDirectory(files[i]); } else { files[i].delete(); return (path.delete()); |
void | deleteDirectory(String directory) delete Directory deleteDirectory(new File(directory));
|
boolean | deleteDirectory(String path) delete Directory return deleteDirectory(new File(path)); |
boolean | deleteDirectory(String path) delete Directory return deleteDirectory(new File(path)); |
void | deleteDirectory(final File directory) Deletes a directory recursively. if (!directory.exists()) { return; if (!isSymbolicLink(directory.toPath())) { cleanDirectory(directory); if (!directory.delete()) { final String message = "Unable to delete directory " ... |
void | deleteFiles(String directory) Deletes all files located in this directory. File dir = new File(directory); String[] list = dir.list(); if (list.length > 0) { for (int i = 0; i < list.length; i++) { File file = new File(directory, list[i]); file.delete(); |
void | deleteFiles(String directory, String dontDelete) Deletes all files in the given directory with the exception of the given file name identified in dontDelete. File dir = new File(directory); String[] list = dir.list(); if (list.length > 0) { for (int i = 0; i < list.length; i++) { File file = new File(directory, list[i]); if (!file.getPath().equalsIgnoreCase(dontDelete)) { file.delete(); |
void | deleteFiles(String directory, String[] dontDelete) Deletes all files in this directory with the exception of the file names given in the dontDelete array. File dir = new File(directory); String[] list = dir.list(); if (dontDelete == null) { deleteFiles(directory); } else if (dontDelete.length == 1 && dontDelete[0] != null) { deleteFiles(directory, dontDelete[0]); } else if (list.length > 0) { for (int i = 0; i < list.length; i++) { ... |
void | deleteSubdirs(String directory) Deletes all subdirectories of the given directory. File parentDir = new File(directory); String[] list = parentDir.list(); File subDir; if (list.length == 0) { return; for (int i = 0; i < list.length; i++) { subDir = new File(directory, list[i]); ... |
boolean | removerDiretorio(File dir) remover Diretorio if (dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { boolean success = removerDiretorio(new File(dir, children[i])); if (!success) { return false; return dir.delete(); |