List of utility methods to do Folder Delete
void | clearFolder(String folder) clear Folder clearFolder(new File(folder));
|
boolean | clearFolder(String path) Delete all files in the directory except folders. boolean flag = true; File dirFile = new File(path); if (!dirFile.isDirectory()) { return flag; File[] files = dirFile.listFiles(); for (File file : files) { if (file.isFile()) { ... |
void | clearFolderContent(String folderName) clear Folder Content File folder = new File(folderName); File[] files = folder.listFiles(); if (files != null) { for (File f : files) { if (f.isDirectory()) { clearFolderContent(f.getAbsolutePath()); } else { f.delete(); ... |
void | deepDelete(final File file) deep Delete if (!file.exists()) return; if (file.isDirectory()) { if (file.list().length == 0) { file.delete(); } else { final String files[] = file.list(); for (final String temp : files) { ... |
void | emptyAndDelete(File fileOrDir) Deletes a file or directory. if (fileOrDir.isDirectory()) { File[] files = fileOrDir.listFiles(); for (File file : files) { emptyAndDelete(file); fileOrDir.delete(); |
void | emptyDerbyTestDirectory(final String derbyTestDirectory) Clean out the test directory. File tempDirectory = new File(derbyTestDirectory); File[] files = tempDirectory.listFiles(); if (files != null) { for (File file : files) { if (file.isDirectory()) { File[] subFiles = file.listFiles(); for (File subFile : subFiles) { if (subFile.isDirectory()) { ... |
void | emptyFile(final String urlFile) Empty a file. final File file = new File(urlFile); if (file.exists()) { if (!file.delete()) { throw new IOException("Failed to delete file : " + file); if (!file.createNewFile()) { throw new IOException("Failed to create file : " + file); ... |
void | emptyFile(String srcFilename) empty File File srcFile = new File(srcFilename); if (!srcFile.exists()) { throw new FileNotFoundException("Cannot find the file: " + srcFile.getAbsolutePath()); if (!srcFile.canWrite()) { throw new IOException("Cannot write the file: " + srcFile.getAbsolutePath()); FileOutputStream outputStream = new FileOutputStream(srcFilename); ... |
boolean | emptyFolder(File dir) Remove all files from a folder, return false if at least one file could not be deleted. if (dir == null) throw new IllegalArgumentException("Null path in FileUtil.emptyFolder()"); if (!dir.isDirectory()) throw new IllegalArgumentException( "Invalid path " + dir.getAbsolutePath() + ": not a directory, in FileUtil.emptyFolder()"); boolean ok = true; File[] files = dir.listFiles(); for (int i = 0; i < files.length && ok; i++) { ... |
void | emptyFolder(File folder) empty Folder if (folder.isDirectory()) { File[] files = folder.listFiles(); for (File file : files) { if (file.isDirectory()) { emptyFolder(file); } else { file.delete(); |