List of utility methods to do Path Delete nio
void | cleanUp(boolean isDeleteOriginalFiles, Path[] filesToZip) clean Up if (isDeleteOriginalFiles) { for (Path fileToZip : filesToZip) { Files.deleteIfExists(fileToZip); |
void | clearAndDeleteDirecotry(Path path) clear And Delete Direcotry clearDirectory(path); path.toFile().delete(); |
FileChannel | createDeleteOnExitFile(Path path) create Delete On Exit File Set<StandardOpenOption> options = new HashSet<>(); options.add(StandardOpenOption.CREATE); options.add(StandardOpenOption.DELETE_ON_CLOSE); options.add(StandardOpenOption.WRITE); return FileSystems.getDefault().provider().newFileChannel(path, options); |
void | delete(@Nullable Path path) delete if (path == null || !exists(path)) { return; if (isRegularFile(path)) { doDelete(path); return; walkFileTree(path, new SimpleFileVisitor<Path>() { ... |
void | delete(final Path path) delete if (Files.exists(path)) { try { if (Files.isDirectory(path)) { try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) { stream.forEach((entry) -> delete(entry)); Files.delete(path); ... |
void | delete(final String[] paths) delete for (final String path : paths) { delete(path); |
void | delete(Path path) delete if (!Files.exists(path)) { return; if (Files.isRegularFile(path)) { Files.delete(path); } else { Files.walkFileTree(path, new SimpleFileVisitor<Path>() { @Override ... |
void | delete(Path path) Deletes file/directory representing the path. if (path.toFile().exists()) { try (Stream<Path> stream = Files.walk(path)) { stream.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); |
void | delete(Path path) Deletes the path from the file system. if (path != null) { try { if (Files.exists(path)) { if (Files.isDirectory(path)) { Files.walkFileTree(path, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { ... |
void | delete(Path root) Deletes the file, if it is a directory, deletes its content recursively. if (Files.isDirectory(root)) { final DirectoryStream<Path> subPaths = Files.newDirectoryStream(root); for (Path path : subPaths) { delete(path); subPaths.close(); Files.delete(root); } else { ... |