Java Utililty Methods Path File Check nio

List of utility methods to do Path File Check nio

Description

The list of methods to do Path File Check nio are organized into topic(s).

Method

booleanisFile(final String path)
Determines whether the given path refers to a valid file
return path != null && Files.isRegularFile(Paths.get(path));
booleanisFile(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();
booleanisFileHidden(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));
booleanisFileSymLink(File path)
returns true if the path specified is actually a symbolic link.
Path nioPath = path.toPath();
return Files.isSymbolicLink(nioPath);
booleanisFileWritable(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)) {
...
booleanisFolder(Path path)
Tests whether a file is a directory.
return Files.isDirectory(path);
booleanisHidden(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);
booleanisHidden(Path path)
is Hidden
try {
    return Files.exists(path) && (Files.isHidden(path) || path.getFileName().toString().startsWith("."));
} catch (Exception e) {
return false;
booleanisHidden(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(".");
booleanisHidden(Path value)
is Hidden
return Files.isHidden(value);