List of utility methods to do Delete File or Directory
void | deleteFileOrDir(File dir, int max) delete File Or Dir File[] listFiles = dir.listFiles(); if (listFiles != null && max > 0) { for (File file : listFiles) { deleteFileOrDir(file, max - 1); dir.delete(); |
void | deleteFileOrDir(File fd) Deletes the directory or file fd from the file system.
boolean deleted = fd.delete(); if (!deleted) { String type = fd.isFile() ? "file" : "directory"; throw new IllegalStateException("Unable to delete " + type + " '" + fd.getPath() + "'"); |
void | deleteFileOrDir(File file) Utility method used to delete the profile directory when run as a stand-alone application. if (file.isDirectory()) { File[] childs = file.listFiles(); for (File child : childs) { deleteFileOrDir(child); file.delete(); |
void | deleteFileOrDir(File file) Utility method used to delete the profile directory when run as a stand-alone application. if (file.isDirectory()) { for (File child : file.listFiles()) { deleteFileOrDir(child); if (!file.delete()) { throw new IOException("Could not remove '" + file + "'!"); |
boolean | deleteFileOrDir(File filehandle) Returns true if all deletions were successful. if (filehandle.isDirectory()) { String[] children = filehandle.list(); for (int i = 0; i < children.length; i++) { boolean success = deleteFileOrDir(new File(filehandle, children[i])); if (!success) { return false; boolean isdel = filehandle.delete(); if (!isdel) { filehandle.deleteOnExit(); return isdel; |
void | deleteFileOrDir(File instanceFileOrDir) delete File Or Dir if (instanceFileOrDir.isDirectory()) { deleteDirectory(instanceFileOrDir); } else { if (!instanceFileOrDir.delete()) { throw new RuntimeException("BB Stoch model factory: Could not delete instance file " + instanceFileOrDir.getAbsolutePath()); |
boolean | deleteFileOrDirectory(File dir) delete a file or directory if (!dir.exists()) return true; if (dir.isFile()) return dir.delete(); File fis[] = dir.listFiles(); for (int i = 0; i < fis.length; i++) deleteFileOrDirectory(fis[i]); return dir.delete(); ... |
void | deleteFileOrDirectory(File file) Delete a directory or file if (file.delete()) System.out.println("Deleted : " + file.getAbsolutePath()); else System.out.println("Failed to delete : " + file.getAbsolutePath()); |
void | deleteFileOrDirectory(File fileOrDirectory) delete File Or Directory if (fileOrDirectory.isDirectory()) { for (File file : fileOrDirectory.listFiles()) deleteFileOrDirectory(file); if (!fileOrDirectory.delete()) { throw new IOException("Failed deleting " + fileOrDirectory); |
void | deleteFileOrDirectory(String fileName) delete File Or Directory File file = new File(fileName); if (file.exists()) { deleteFileOrDirectory(file); throw new IllegalArgumentException("file:[" + fileName + "] not exists,please check it!"); |