List of utility methods to do File Delete
void | forceDelete(String file) force Delete forceDelete(new File(file));
|
void | forceDelete(final File file) Deletes a file. if (file == null) { return; if (file.isDirectory()) { deleteDirectory(file); } else { final boolean filePresent = file.exists(); if (!file.delete()) { ... |
boolean | recursiveDelete(File fileOrDir) Recursively delete file or directory l.debug("Deleting " + fileOrDir + " recursively."); if (fileOrDir.isDirectory()) { for (File innerFile : fileOrDir.listFiles()) { if (!recursiveDelete(innerFile)) { return false; l.debug("Deleted" + fileOrDir + " recursively."); return fileOrDir.delete(); |
boolean | recursiveDelete(File path) recursive Delete if (path.isDirectory()) { File[] files = path.listFiles(); if (files != null) { for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { recursiveDelete(files[i]); } else { files[i].delete(); ... |
File | removeableFile(File folder, String fileName) removeable File File file = new File(folder, fileName); file.deleteOnExit(); return file; |
boolean | renameFile(String strSrc, String strDest, boolean deleteIfExist) Rename file from source to destination File flSrc = new File(strSrc); File flDest = new File(strDest); if (flSrc.getAbsolutePath().equals(flDest.getAbsolutePath())) return false; if (flDest.exists()) { if (deleteIfExist) flDest.delete(); else ... |
void | safelyDeleteFile(File filePath) safely Delete File if (filePath != null && filePath.exists()) {
filePath.delete();
|
void | safelyDeleteFile(String filePath) safely Delete File safelyDeleteFile(new File(filePath));
|
void | deleteFolderFile(String filePath, boolean deleteThisPath) delete Folder File if (!TextUtils.isEmpty(filePath)) { File file = new File(filePath); if (file.isDirectory()) { File files[] = file.listFiles(); for (int i = 0; i < files.length; i++) { deleteFolderFile(files[i].getAbsolutePath(), true); if (deleteThisPath) { if (!file.isDirectory()) { file.delete(); } else { if (file.listFiles().length == 0) { file.delete(); |
void | deleteFile(File f) delete File if (f.isDirectory()) { for (File f2 : f.listFiles()) deleteFile(f2); if (!f.delete()) throw new RuntimeException("Unable to delete file: " + f); |