List of utility methods to do Path File Name nio
String | getLatestUpgradeScriptName(Path upgradeScriptsDir) get Latest Upgrade Script Name List<String> fileNames = new ArrayList<>(); DirectoryStream.Filter<Path> fileFilter = new DirectoryStream.Filter<Path>() { public boolean accept(Path file) throws IOException { return !Files.isDirectory(file); }; try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(upgradeScriptsDir, fileFilter)) { for (Path path : directoryStream) { ... |
String | getLocalFilePath(String localDirectory, String filename) get Local File Path if (localDirectory != null) { return getPath(localDirectory, filename); return filename; |
String | getManifestProperty(Path pathToJar, String propertyName) get Manifest Property File file = pathToJar.toFile(); try (JarFile jar = new JarFile(file)) { Manifest manifest = jar.getManifest(); Attributes attributes = manifest.getMainAttributes(); return attributes.getValue("Bundle-Version"); |
String | getName(Path file) get Name Path name = file.getFileName(); return name == null ? "" : name.toString(); |
String | getName(Path path) get Name return getFileName(path);
|
String | getName(Path path) get Name return Optional.ofNullable(path.getFileName()).map(Path::toString) .orElseThrow(() -> new IllegalStateException(path.toString())); |
String | getName(Path path) Returns the name of the file or directory from the given path. return path.getFileName().toString();
|
String | getName(String path) Get the name and extension of a file return getName(Paths.get(path));
|
String | getNamePart(Path file) get Name Part String s = file.getFileName().toString();
return getNamePart(s);
|
String | getNameWithoutSuffix(Path path) get Name Without Suffix String name = path.getFileName().toString(); int index = name.lastIndexOf('.'); if (index == -1) { return name; return name.substring(0, index); |