List of utility methods to do File Path Delete
void | delAll(String path) del All File f = new File(path); if (f.isDirectory()) { String[] children = f.list(); for (String folder : children) { String newPath = path + "/" + folder; delAll(newPath); f.delete(); |
void | delAllFile(String path) delete all files inside folder File file = new File(path); if (!file.exists()) { return; if (!file.isDirectory()) { return; if (file.getAbsolutePath().equalsIgnoreCase("/")) { ... |
boolean | delAllFiles(File dir, String prefix) del All Files boolean bUnableToDeleteSomeFiles = false; String[] fileList = dir.list(); String path = dir.getAbsolutePath() + File.separator; File file; for (int i = 0; i < fileList.length; ++i) { if (fileList[i].startsWith(prefix)) { try { file = new File(path + fileList[i]); ... |
void | delAllFiles(File dir, String suffix) del All Files List files = findAllFiles(dir, suffix);
for (Iterator it = files.iterator(); it.hasNext();) {
File file = (File) it.next();
file.delete();
|
void | delDir(String path) del Dir File dir = new File(path); if (dir.exists()) { dir.delete(); |
void | delDirAndFile(String tempath) del Dir And File File f = new File(tempath); if (f.isDirectory()) { File[] l = f.listFiles(); for (int i = 0; i < l.length; i++) { delDirAndFile(l[i].getAbsolutePath()); f.delete(); ... |
int | deleleFiles(String regex, String path) delele Files int rtn = 0; if (path != null && regex != null) { File folder = new File(path); File[] files = folder.listFiles(); for (int i = 0; i < files.length; i++) { String fname = files[i].getName(); if (fname.matches(regex)) { if (files[i].delete()) { ... |
void | delEmptyPath(String path) del Empty Path File file = new File(path); if (file.exists() && file.isDirectory()) { File[] files = file.listFiles(); if (files != null && files.length > 0) return; if (file.delete()) { delEmptyPath(file.getParent()); |
void | delete(File path) delete if (!path.delete()) throw new RuntimeException("Could not delete " + path.getAbsolutePath()); |
boolean | delete(File path) Delete the whole directory boolean res = true, tmp = true; if (path.exists()) { File[] files = path.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { tmp = delete(files[i]); } else { tmp = deleteFile(files[i]); ... |