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

booleanisRegularUsable(final Path pathToFile, final LinkOption... linkOption)
Return whether the file detonated by the Path Path pathToFile is existing, a regular file and readable.
return Files.exists(pathToFile, linkOption) && Files.isRegularFile(pathToFile, linkOption)
        && Files.isReadable(pathToFile);
booleanisSame(Path expected, Path actual)
Tests if two paths locate the same file.
return Files.isSameFile(expected, actual);
booleanisSameFile(Path path1, Path path2)
is Same File
try {
    return path1.equals(path2) || Files.isSameFile(path1, path2);
} catch (IOException e) {
    return false;
booleanisSteadyStateReached(Path integrationStepFile, double minStepAtEndOfStabilization)
is Steady State Reached
if (Files.exists(integrationStepFile)) {
    try (Stream<String> stream = Files.lines(integrationStepFile)) {
        double[] values = stream.mapToDouble(Double::parseDouble).toArray();
        if (values.length <= 1) {
            return false;
        } else {
            return values[values.length - 2] >= minStepAtEndOfStabilization;
} else {
    return false;
booleanisUNC(Path inputPath)
Test if a Path is UNC.
if (inputPath != null) {
    return isUNC(inputPath.toString());
} else {
    return false;
booleanisUnix(Path path)
is Unix
return path.getFileSystem().supportedFileAttributeViews().contains("unix");
booleanisValidDirectory(String path)
Determines whether given path is a valid directory
return path.length() > 0 & path.charAt(0) == '/' & Files.isDirectory(Paths.get(path));
booleanisValidFileType(Path filePath)
Checks if the given file path is valid for monitoring (i.e is a class or resource file).
for (String fileType : fileTypesToWatch) {
    if (filePath != null && filePath.getFileName().toString().endsWith(fileType)) {
        return true;
return false;
booleanisValidHomeDirectory(final Path path)
Checks whether or not the directory is a valid home directory for a server.
return path != null && Files.exists(path) && Files.isDirectory(path)
        && Files.exists(path.resolve("jboss-modules.jar"));
booleanisValidPath(String path)
Check whether a path is valid and parsable, without the file needing to exist.
try {
    Paths.get(path);
    return true;
} catch (Exception ignored) {
return false;