List of utility methods to do File Path Delete
boolean | deleteDir(File path) Deletes a given File , if it exists. if (path == null) { throw new NullPointerException("Path cannot be null!"); if (!path.exists()) { throw new FileNotFoundException("File not found: " + path); boolean result = true; if (path.isDirectory()) { ... |
boolean | deleteDir(File path) delete Dir if (path.exists()) { File[] files = path.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { deleteDir(files[i]); } else { files[i].delete(); boolean ok = path.delete(); if (!ok) System.err.println("[WARN] Unable to delete: " + path); return ok; |
void | deleteDir(final String path) delete Dir File file = new File(path);
deleteDir(file);
|
boolean | deleteDir(String path) Deletes a file or directory. return deleteDir(new File(path)); |
boolean | deleteDir(String path) delete Dir File dir = new File(path); return deleteDir(dir); |
int | deleteDirByDoc(String path) delete Dir By Doc path = path.replaceAll("/", "\\\\"); path = path.replaceAll("\\\\\\\\", "\\\\"); if (new File(path).exists()) { Runtime runtime = Runtime.getRuntime(); try { runtime.exec("cmd /c rd /s/q " + path); return 0; } catch (IOException e) { ... |
boolean | deleteDirectory(File directoryPath) Utility method for deleting a folder. boolean deleated = true; if (directoryPath.exists() && directoryPath.isDirectory()) { if (directoryPath.list().length > 0) { for (File f : directoryPath.listFiles()) { if (f.isFile()) { if (!f.delete()) { deleated = false; } else { if (!deleteDirectory(f)) { deleated = false; if (!directoryPath.delete()) { deleated = false; } else { if (!directoryPath.delete()) { deleated = false; return deleated; |
boolean | deleteDirectory(File path) delete Directory if (path.exists()) { File[] files = path.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { deleteDirectory(files[i]); } else { System.out.println("file deleted: " + files[i].getPath()); files[i].delete(); ... |
void | deleteDirectory(File path) delete Directory if (path != null && path.exists()) { if (path.isDirectory()) { for (File f : path.listFiles()) { deleteDirectory(f); path.delete(); |
boolean | deleteDirectory(File path) Tries to delete a directory and all contained files and subdirectories if (!path.exists()) { return true; if (path.exists()) { File[] files = path.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { deleteDirectory(files[i]); ... |