List of utility methods to do Directory Delete nio
void | deleteDir(File dir) delete Dir Files.walkFileTree(dir.toPath(), nukeVisitor); |
void | deleteDir(File file) delete Dir File[] files = file.listFiles(); if (files != null) { for (File temp : files) { deleteDir(temp); try { Files.deleteIfExists(file.toPath()); ... |
void | deleteDir(final File targetDir) Elimina un directorio con todo su contenido. try { Files.walkFileTree(targetDir.toPath(), new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException { Files.delete(file); return FileVisitResult.CONTINUE; @Override public FileVisitResult postVisitDirectory(final Path dir, final IOException e) throws IOException { if (e != null) { throw e; Files.delete(dir); return FileVisitResult.CONTINUE; }); } catch (final Exception e) { LOGGER.warning("No se pudo borrar el directorio '" + targetDir.getAbsolutePath() + "': " + e); |
void | deleteDir(String dirName) delete Dir deleteDir(new File(dirName));
|
void | deleteDir(String path) delete Dir if (new File(path).exists()) Files.walkFileTree(Paths.get(path), new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Files.delete(file); return FileVisitResult.CONTINUE; @Override ... |
void | deleteDirectory(File dir) Deletes a directory recursively. Files.walk(dir.toPath()).map(Path::toFile).sorted(Comparator.reverseOrder()).forEach(File::delete); |
void | deleteDirectory(File dir) delete Directory if (dir.exists() && dir.isDirectory()) { for (File child : dir.listFiles()) { if (child.isDirectory()) { deleteDirectory(child); } else { Files.delete(child.toPath()); Files.delete(dir.toPath()); |
boolean | deleteDirectory(File directory) Delete the given directory along with all files and sub directories. try { Files.walk(directory.toPath(), FileVisitOption.FOLLOW_LINKS).sorted(Comparator.reverseOrder()) .map(Path::toFile).forEach(File::delete); } catch (IOException e) { return false; return true; |
boolean | deleteDirectory(File directory) delete Directory if (!directory.exists()) return true; try { Files.delete(directory.toPath()); catch (DirectoryNotEmptyException e) { if (directory.listFiles() == null) return false; ... |
boolean | deleteDirectory(File directory) delete Directory checkNotNull(directory); checkArgument(directory.isDirectory(), "File is not directory."); try { Files.walkFileTree(directory.toPath(), new SimpleFileVisitor<Path>() { @Nonnull @Override public FileVisitResult visitFile(@Nonnull Path file, @Nonnull BasicFileAttributes attrs) throws IOException { ... |