List of utility methods to do Path File Check nio
boolean | isRegularUsable(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);
|
boolean | isSame(Path expected, Path actual) Tests if two paths locate the same file. return Files.isSameFile(expected, actual);
|
boolean | isSameFile(Path path1, Path path2) is Same File try { return path1.equals(path2) || Files.isSameFile(path1, path2); } catch (IOException e) { return false; |
boolean | isSteadyStateReached(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; |
boolean | isUNC(Path inputPath) Test if a Path is UNC. if (inputPath != null) { return isUNC(inputPath.toString()); } else { return false; |
boolean | isUnix(Path path) is Unix return path.getFileSystem().supportedFileAttributeViews().contains("unix"); |
boolean | isValidDirectory(String path) Determines whether given path is a valid directory return path.length() > 0 & path.charAt(0) == '/' & Files.isDirectory(Paths.get(path)); |
boolean | isValidFileType(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; |
boolean | isValidHomeDirectory(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")); |
boolean | isValidPath(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; |