List of utility methods to do Directory Clear
void | cleanDirectory(File dir) clean Directory File[] files = dir.listFiles(); if (files != null) { for (File f : files) { if (f.isFile()) { boolean deleted = f.delete(); if (!deleted) { throw new IOException("file:" + f.getAbsolutePath() + " not deleted"); } else { deleteDirectory(f); |
void | cleanDirectory(File dir) clean Directory if (dir.exists() && dir.isDirectory()) { for (File f : dir.listFiles()) { deleteRecursively(f); |
void | cleanDirectory(File dir) Cleans the content of the specified directory recursively. File[] files = dir.listFiles(); if (files != null && files.length > 0) { for (File file : files) { delete(file); |
boolean | cleanDirectory(File dir) clean Directory if (!dir.isDirectory()) return false; for (File file : dir.listFiles()) { if (!deleteRecursive(file)) return false; return true; |
File | cleanDirectory(File dir) clean Directory if (dir.isFile()) { return null; delete(dir); dir.mkdirs(); return dir; |
boolean | cleanDirectory(File dir, boolean deleteDirectory) Cleans up the dir and deletes it. if (!dir.exists()) { return true; if (!dir.isDirectory()) { throw new IllegalArgumentException(dir.getAbsolutePath() + " is not a directory"); File[] files = dir.listFiles(); if (files == null) { ... |
void | cleanDirectory(File directory) clean Directory if (!directory.exists()) { String message = directory + " does not exist"; throw new IllegalArgumentException(message); if (!directory.isDirectory()) { String message = directory + " is not a directory"; throw new IllegalArgumentException(message); File[] files = directory.listFiles(); for (int i = 0; i < files.length; i++) { File file = files[i]; if (file.isDirectory()) { deleteDirectory(file); } else { file.delete(); |
void | cleanDirectory(File directory) Deletes a directory (including any contents) and recreates it so that it is empty deleteDirectory(directory); if (!directory.mkdirs()) throw new IOException("Directory could not be re-created during clean: " + directory.getAbsolutePath()); |
void | cleanDirectory(File directory) clean Directory File[] files = directory.listFiles(); if (files != null) { for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { cleanDirectory(files[i]); files[i].delete(); |
void | cleanDirectory(File directory) clean Directory if (!directory.exists()) { String message = directory + " does not exist"; throw new IllegalArgumentException(message); if (!directory.isDirectory()) { String message = directory + " is not a directory"; throw new IllegalArgumentException(message); File[] files = directory.listFiles(); if (files == null) { throw new IOException("Failed to list contents of " + directory); IOException exception = null; for (File file : files) { try { delete(file); } catch (IOException ioe) { exception = ioe; if (null != exception) { throw exception; |