List of utility methods to do Path Exist nio
boolean | exists(Path... files) Returns true iff one of the files exists otherwise false
for (Path file : files) { if (Files.exists(file)) { return true; return false; |
boolean | exists(String path) Answers if the given path denotes existing directory. if (path == null) return false; Path p = Paths.get(path); return Files.exists(p) && Files.isDirectory(p) && Files.isReadable(p); |
boolean | existsAndIsDirectory(Path path) exists And Is Directory return Files.exists(path) && Files.isDirectory(path);
|
boolean | fileExists(Path path) file Exists return path.toFile().exists();
|
Path | getNonExisting(Path path) get Non Existing if (!Files.exists(path)) { return path; final String name = path.getFileName().toString(); final int fileTypeIndex = name.lastIndexOf("."); String nameWithoutExtension; String extension; if (fileTypeIndex == -1) { ... |
Boolean | isExists(final Path path) is Exists return path.toFile().exists();
|
boolean | isFileExists(Path file) is File Exists return Files.exists(file) && Files.isRegularFile(file);
|
boolean | lenientExists(Path file) lenient Exists boolean exists = false; try { exists = Files.exists(file); } catch (SecurityException ok) { return exists; |
Path | makeTempFilePath(boolean exists) make Temp File Path Path result; if (System.getenv().containsKey("TEST_TMPDIR")) { result = Files.createTempFile(Paths.get(System.getenv("TEST_TMPDIR")), "", "json"); } else { result = Files.createTempFile("", "json"); if (!exists) { Files.delete(result); ... |