List of utility methods to do File Delete nio
void | delete(File f) delete if (f.isDirectory() && !Files.isSymbolicLink(Paths.get(f.toURI()))) { for (File c : f.listFiles()) { delete(c); f.delete(); |
void | delete(File file) Deletes a file recursively. if (file.isDirectory()) { File[] children = file.listFiles(); if (children == null) { String msg = "Could not access content of " + file.getAbsolutePath(); throw new IOException(msg); for (File f : children) delete(f); ... |
boolean | delete(File file) delete return delete(file.toPath());
|
void | delete(File file) delete if (file.isFile()) { deleteQuietly(file); } else if (file.isDirectory()) { Path directory = file.toPath(); try { Files.walkFileTree(directory, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { ... |
boolean | delete(File file) delete if (!file.exists()) return true; try { final FileSystem fileSystem = FileSystems.getDefault(); final Path path = fileSystem.getPath(file.getAbsolutePath()); Files.delete(path); return true; } catch (FileSystemException e) { ... |
void | delete(File file) delete for (int n = 0; n < 10; n++) { try { Files.delete(file.toPath()); if (Files.exists(file.toPath())) { Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS); continue; return; ... |
void | delete(File file) Recursively delete a file or directory. if (!file.exists()) return; if (file.isDirectory()) { for (File child : listFiles(file)) { delete(child); Files.delete(file.toPath()); ... |
void | delete(File file) delete if (file.isDirectory()) { deleteDirectory(file); return; Files.delete(Paths.get(file.getPath())); |
void | delete(File toRecurse) delete Files.walk(toRecurse.toPath(), FileVisitOption.FOLLOW_LINKS).sorted(Comparator.reverseOrder()) .map(Path::toFile).forEach(File::delete); |
void | delete(final File directory, final FileFilter fileFilter) delete if (!directory.exists() || !directory.isDirectory()) throw new FileNotFoundException("No directory found at " + directory); for (File file : directory.listFiles(fileFilter)) Files.delete(file.toPath()); |