List of utility methods to do File Delete
boolean | deleteFile(String strSrc) Delete file File flSrc = new File(strSrc); return flSrc.delete(); |
void | deleteFileOnly(String path) delete File Only File file = new File(path); if (file.exists() && file.isFile()) { file.delete(); |
boolean | deleteFiles(File file) delete Files return deleteFiles(file, ".*"); |
boolean | deleteFiles(File file, String regex) recursively delete all sub files which matches regular expression if (!file.exists()) return true; if (file.isDirectory()) { File[] subFiles = file.listFiles(); for (File subFile : subFiles) { if (!deleteFiles(subFile, regex)) return false; } else if (file.getName().matches(regex)) return file.delete(); return true; |
void | deleteFilesRecursive(File src) delete all the files in a directory recursively if (!src.exists()) { if (!src.mkdirs()) { throw new IOException( "deleteFiles: Could not create direcotry: " + src.getAbsolutePath() + "."); } else if (!src.canRead()) { throw new IOException("copyFiles: No right to source: " ... |
boolean | deleteFolder(File targetFolder) delete Folder try { File[] childFile = targetFolder.listFiles(); if (childFile == null) { return !targetFolder.exists(); int size = childFile.length; if (size > 0) { for (int i = 0; i < size; i++) { ... |
void | deleteFolders(File dir) delete Folders if (dir.isDirectory()) { File[] children = dir.listFiles(); for (File child : children) { deleteFolders(child); dir.delete(); |
void | deleteIfExists(File file) Calls #delete delete (file) if file != null and file exists.
if ((file != null) && file.exists())
delete(file);
|
void | deleteOldFile(String strPath, String strWildcard, int iOffset) Delete unused file |
boolean | deleteRecursively(File dir) Deletes a file recursively. if (dir == null) { return false; boolean result = true; if (dir.isDirectory()) { for (File child : dir.listFiles()) { result = result && deleteRecursively(child); return result && dir.delete(); |