List of utility methods to do File Delete nio
boolean | deleteIfEmpty(final File directory) delete If Empty if (directory.list().length > 0) return false; Files.delete(directory.toPath()); return true; |
void | deleteLocalFile(final String fileName) delete Local File Files.deleteIfExists(Paths.get(DOWNLOAD_BASE_NAME + fileName)); |
void | deleteLocalFileOrDirectory(File file) Delete a local file or directory. if (file.isFile()) { Files.delete(file.toPath()); } else if (file.isDirectory()) { deleteLocalDirectory(file); |
void | deleteMatching(File baseFile, String regex) Destroys all files that match the given regex that are in the given directory. if (baseFile.exists() && baseFile.isDirectory()) { for (File child : listFiles(baseFile)) { if (child.getName().matches(regex)) { try { delete(child); } catch (IOException ignore) { |
boolean | deletePidFile() delete Pid File Path file = Paths.get(System.getProperty("java.io.tmpdir"), NEO4J_ETL_UI_PID_FILE_NAME); return file.toFile().delete(); |
void | deleteQuietly(File file) delete Quietly try { Files.deleteIfExists(file.toPath()); } catch (Exception e) { |
boolean | deleteRecursive(File fileOrDirectory) Remove specified file or directory. if (fileOrDirectory.isDirectory()) { File[] list = fileOrDirectory.listFiles(); if (list == null) { return false; for (File f : list) { if (!deleteRecursive(f)) { return false; ... |
void | deleteRecursively(File fileOrDir) delete Recursively if (fileOrDir.isDirectory() && !Files.isSymbolicLink(fileOrDir.toPath())) for (File f : fileOrDir.listFiles()) deleteRecursively(f); fileOrDir.delete(); |
boolean | deleteRecursively(File root) delete Recursively if (root == null) { return false; try { return deleteRecursively(root.toPath()); } catch (IOException ex) { return false; |
void | deleteTestFile(String extension) delete Test File deleteFile(Paths.get("./test" + extension).toString());
|