List of utility methods to do Delete Directory
void | deleteDirectoryContents(File directory) Delete the files in directory. Preconditions.checkArgument(directory.isDirectory(), "Not a directory: %s", directory); File[] files = directory.listFiles(); if (files == null) { throw new IOException("Error listing files for " + directory); for (File file : files) { deleteRecursively(file); |
void | deleteDirectoryContents(File directory) Same as calling #deleteDirectoryContents(File,boolean) deleteDirectoryContents(directory, false) . deleteDirectoryContents(directory, false); |
void | deleteDirectoryContents(File directory) Wipes out all the a directory starting from a given directory. Preconditions.checkArgument(directory.isDirectory(), "Not a directory: %s", directory); Deque<File> stack = Queues.newArrayDeque(); stack.add(directory); while (!stack.isEmpty()) { File file = stack.peekLast(); File[] files = file.listFiles(); if (files == null || files.length == 0) { file.delete(); ... |
void | deleteDirectoryContents(File directory) delete Directory Contents if (!directory.getCanonicalPath().equals(directory.getAbsolutePath())) { File[] files = directory.listFiles(); if (files == null) { throw new IOException("Error listing files for " + directory); for (File file : files) { deleteRecursively(file); ... |
boolean | deleteDirectoryContents(final File dir) Recursively deletes all files and folders within the directory dir. if (dir == null || !dir.isDirectory()) { return false; File[] files = dir.listFiles(); for (final File file : files) { if (file.isDirectory()) { if (!deleteDirectory(file)) { return false; ... |
void | deleteDirectoryContents(final File dir, int deleteDirLevel, int level) delete Directory Contents if ((dir == null) || !dir.isDirectory()) { return; final File[] files = dir.listFiles(); if (files != null) { for (final File f : files) { if (f.isDirectory()) { deleteDirectoryContents(f, deleteDirLevel, level + 1); ... |
void | deleteFiles(File dir) Deletes all files in a directory, but leaving the directory otherwise unmodified. if (dir != null && dir.isDirectory()) { File[] files = dir.listFiles(); if (files != null) { for (int i = 0; i < files.length; i++) { delete(files[i]); |
void | deleteFiles(File dir) delete Files File[] files = dir.listFiles(); if (files == null) return; for (int i = 0; i < files.length; i++) { File file = files[i]; if (file.isDirectory()) deleteFiles(file); file.delete(); ... |
void | deleteFiles(File directory) delete Files if (directory != null) { for (File file : directory.listFiles()) { if (file.isDirectory()) { deleteDirectory(file); if (!file.delete()) { file.deleteOnExit(); |
boolean | deleteFiles(File directory) Deletes all files and directories in the specified directory. boolean result = true; if (directory.isDirectory()) { File[] list = directory.listFiles(); for (int i = list.length; i-- > 0;) { File file = list[i]; if (file.isFile()) { result = result && file.delete(); return result; |