List of utility methods to do Path File Check nio
boolean | isFile(final String path) Determines whether the given path refers to a valid file return path != null && Files.isRegularFile(Paths.get(path));
|
boolean | isFile(Path file) We are using java.io because sonar has suggested as a performance update https://sonarqube.com/coding_rules#rule_key=squid%3AS3725 return file != null && file.toFile().isFile();
|
boolean | isFileHidden(Path file) is File Hidden List<String> illegal = new ArrayList<String>(); illegal.add("$"); illegal.add("."); illegal.add("~"); return illegal.stream().anyMatch(pattern -> file.getFileName().toString().startsWith(pattern)); |
boolean | isFileSymLink(File path) returns true if the path specified is actually a symbolic link. Path nioPath = path.toPath();
return Files.isSymbolicLink(nioPath);
|
boolean | isFileWritable(final Path file) Checks if an output file can be written. if (file == null) { return false; if (isDirectory(file)) { return false; final Path parentPath = file.getParent(); if (parentPath == null || !exists(parentPath) || !isDirectory(parentPath) || !isWritable(parentPath)) { ... |
boolean | isFolder(Path path) Tests whether a file is a directory. return Files.isDirectory(path);
|
boolean | isHidden(final Path path) Due to the way that windows handles hidden files vs. if (System.getProperty("os.name").contains("Windows")) { return Files.readAttributes(path, DosFileAttributes.class).isHidden(); return Files.isHidden(path); |
boolean | isHidden(Path path) is Hidden try { return Files.exists(path) && (Files.isHidden(path) || path.getFileName().toString().startsWith(".")); } catch (Exception e) { return false; |
boolean | isHidden(Path path) Check whether the file denoted by the given path is hidden. Path fileName = path.getFileName(); if (fileName == null) { return false; return fileName.toString().startsWith("."); |
boolean | isHidden(Path value) is Hidden return Files.isHidden(value);
|