List of utility methods to do File Delete nio
void | forceDelete(File file) force Delete if (file.isDirectory()) { deleteDirectory(file); } else { final boolean filePresent = file.exists(); if (!file.delete()) { if (!filePresent) throw new FileNotFoundException("File does not exist: " + file); final String message = "Unable to delete file: " + file; ... |
void | forceDelete(File file) Deletes a file. if (file.isDirectory()) { deleteDirectory(file); } else { Files.delete(file.toPath()); |
void | forceDelete(final File file) Deletes a file. if (file == null) { return; if (file.isDirectory()) { deleteDirectory(file); } else { final boolean filePresent = file.exists(); if (!file.delete()) { ... |
void | forceDeletion(File fileToDelete) Forces the deletion of the specified file. if (fileToDelete.exists() && !fileToDelete.canWrite()) { fileToDelete.setWritable(true); try (Stream<Path> paths = Files.walk(fileToDelete.toPath())) { paths.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); |
void | recDeleteDirFile(File f) Deletes the file passed in. if (f.isFile()) { Files.delete(f.toPath()); } else if (f.isDirectory()) { for (File file : f.listFiles()) { if (file.isDirectory()) { recDeleteDirFile(file); Files.delete(file.toPath()); ... |
boolean | recursiveDelete(File parent) recursive Delete if (parent.exists()) { if (parent.isDirectory()) { File[] files = parent.listFiles(); for (int ifile = 0; ifile < files.length; ++ifile) { if (files[ifile].isDirectory()) { recursiveDelete(files[ifile]); if (files[ifile].exists()) { ... |
void | safeDeleteFile(final String fileName) safe Delete File final FileSystem fs = FileSystems.getDefault(); final Path pdfFilePath = fs.getPath(fileName); try { Files.delete(pdfFilePath); } catch (Exception ex) { } finally { |
void | secureDelete(File file) Securely deletes a file. secureDelete(file, 1); |