List of utility methods to do Directory Clean
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); IOException exception = null; File[] files = directory.listFiles(); for (File file : files) { try { forceDelete(file); } catch (IOException ioe) { exception = ioe; if (null != exception) { throw exception; } else { return; |
void | cleanDirectory(File directory) Cleans a directory without deleting it. 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 (int i = 0; i < files.length; i++) { File file = files[i]; try { forceDelete(file); } catch (IOException ioe) { exception = ioe; if (null != exception) { throw exception; |
void | cleanDirectory(String directory) clean Directory cleanDirectory(new File(directory));
|
void | cleanDirectory(final File directory) Clean a directory without delete it if (!directory.exists()) { final String message = directory + " does not exist"; throw new IllegalArgumentException(message); if (!directory.isDirectory()) { final String message = directory + " is not a directory"; throw new IllegalArgumentException(message); final File[] files = directory.listFiles(); if (files == null) { throw new IOException("Failed to list content of " + directory); IOException exception = null; for (final File file : files) { try { forceDelete(file); } catch (final IOException ioe) { exception = ioe; if (null != exception) { throw exception; |
void | clearDir(String dirPath) clear Dir if (StringUtil.isEmpty(dirPath)) { return; File file = new File(dirPath); if (!file.exists() || file.isFile()) { return; File[] files = file.listFiles(); ... |