List of utility methods to do Path File Check nio
boolean | isValidPath(String path) Returns true if path can be converted into a Path via Paths#get(String) , otherwise returns false. try { Paths.get(path); } catch (InvalidPathException ipe) { return false; return true; |
boolean | isValidPath(String path) is Valid Path try { Paths.get(path); } catch (InvalidPathException ex) { return false; return true; |
boolean | isValidRootArgument(Path argument) is Valid Root Argument return (Files.exists(argument) && Files.isDirectory(argument));
|
boolean | isValidWildFlyHome(final Path path) Validates the path is a valid WildFly directory by checking for a jboss-modules.jar . return Files.exists(path.resolve("jboss-modules.jar")); |
boolean | isVideo(Path p) is Video return Files.probeContentType(p).matches("video/.*"); |
boolean | isZip(Path path) Helper method to check zip path. return path.getClass().getSimpleName().endsWith("ZipPath"); |
boolean | isZip(Path path) is Zip if (!Files.isRegularFile(path)) { return false; try (ZipFile ignored = new ZipFile(path.toFile())) { return true; } catch (IOException ignored) { return false; |
boolean | isZipFile(Path path) Return true only if path is a zip file. return Files.isRegularFile(path) && path.toString().toLowerCase().endsWith(".zip"); |
boolean | isZipFile(Path path) Check if the file matching the given path is a zip file or not. File f = path.toFile(); if (f.isDirectory() || f.length() < 4) { return false; try (DataInputStream inputStream = new DataInputStream(new FileInputStream(f))) { return inputStream.readInt() == 0x504b0304; } catch (FileNotFoundException e) { return false; ... |