List of utility methods to do Delete Folder
boolean | deleteFolder(@Nonnull File file) delete Folder if (file.exists()) { boolean result = true; if (file.isDirectory()) { File[] contents = file.listFiles(); if (contents != null) { for (File f : contents) { result = result && deleteFolder(f); return result && file.delete(); return false; |
void | deleteFolder(File dir, boolean deleteFolderItself) Deletes given folder with all of its content File[] files = dir.listFiles(); for (int i = 0; i < files.length; i++) { File f = files[i]; if (f.isDirectory()) { deleteFolder(f, true); } else if (f.isFile()) { if (!f.delete()) { System.err.println("Cannot delete file " + f.getAbsolutePath()); ... |
void | deleteFolder(File file) delete Folder if (!file.isDirectory() || (file.isDirectory() && file.list().length == 0)) { file.delete(); } else { File[] listFiles = file.listFiles(); for (File childFile : listFiles) { deleteFolder(childFile); file.delete(); ... |
boolean | deleteFolder(File file) delete Folder File[] flist = null; if (file == null) { return false; if (file.isFile()) { return file.delete(); if (!file.isDirectory()) { ... |
boolean | deleteFolder(File file) Used to delete a folder. if (file.exists()) { boolean ret = true; if (file.isDirectory()) { for (File f : file.listFiles()) { ret = ret && deleteFolder(f); return ret && file.delete(); ... |
void | deleteFolder(File file, boolean deleteParent) delete Folder File[] list = file.listFiles(); if (list == null || list.length < 1) { if (deleteParent) file.delete(); return; for (File ele : list) { if (ele.isDirectory()) ... |
void | deleteFolder(File file, boolean withCurrentFolder) Delete the sub folders, if true, will delete current folder also. if (file.exists() && file.isDirectory()) { File files[] = file.listFiles(); for (File file2 : files) { deleteFile(file2, true); if (withCurrentFolder) { file.delete(); |
boolean | deleteFolder(File folder) Deletes the folder and all of its contents if (!folder.exists()) return false; if (!folder.isDirectory()) return false; if (!cleanFolder(folder)) return false; return folder.delete(); |
void | deleteFolder(File folder) This method deletes a folder including all subfolders and files. if (folder.exists()) { for (File child : folder.listFiles()) { if (child.isDirectory()) { deleteFolder(child); } else { if (!child.delete()) { throw new IOException("Deletion of file: " + child.getAbsolutePath() + " failed."); if (!folder.delete()) { throw new IOException("Deletion of folder: " + folder.getAbsolutePath() + " failed."); |
boolean | deleteFolder(File folder) delete Folder return deleteFolderContents(folder) && folder.delete();
|