List of utility methods to do Path Resolve nio
String | getResolvableFilePath(String path) Convert path string to validated file path string. return getResolvableFilePath(Paths.get(path));
|
Path | resolve(final Optional Attempts to resolve the child against the parent. return parent.map(p -> p.resolve(child)).orElse(Paths.get(child));
|
Path | resolve(Path base, String one, String... more) resolve if (more == null || more.length < 1) { return base.resolve(one); StringBuilder builder = new StringBuilder(one); for (String block : more) { builder.append('/').append(block); return base.resolve(builder.toString()); ... |
Path | resolve(Path directory, String... parts) Resolves the Path to the file or directory under the directory/parts[0]/parts[1]/.../parts[n] .
Path current = directory; for (String part : parts) { current = current.resolve(part); return current; |
Path | resolve(Path file, Path srcDir, Path destDir) resolve return destDir.resolve(srcDir.relativize(file));
|
Path | resolve(Path path1, Path path2) Resolves paths, even if their file system are different. if (path1.getFileSystem().equals(path2.getFileSystem())) { return path1.resolve(path2); } else { if (path2.isAbsolute()) { return path2; } else { Path resolvedPath = path1; for (Path pathPart : path2) { ... |
List | resolve(Path target, Collection resolve List<Path> resolvedPaths = new ArrayList<>(); for (Path child : paths) { resolvedPaths.add(target.resolve(child)); return resolvedPaths; |
Optional | resolve(Path workingDir, List resolve paths.add(workingDir); Optional<Path> resolved = Optional.empty(); for (Path path : paths) { if (Files.exists(path) && !Files.isDirectory(path)) path = path.getParent(); Path possibility = path.resolve(file).normalize(); if (Files.exists(possibility) && !Files.isDirectory(possibility)) { resolved = Optional.of(possibility); ... |
Path | resolveBagUri(final Path baseDir, final URI bagUri) Resolves the supplied bag:// URI against a platform-specific base directory. if (bagUri == null) { throw new IllegalArgumentException( String.format(ERR_RESOLVE_BAGURI + "bag uri was null.", "null", baseDir)); if (!bagUri.getScheme().equals(BAG_URI_SCHEME)) { throw new IllegalArgumentException( String.format(ERR_RESOLVE_BAGURI + "bag uri had incorrect scheme.", bagUri, baseDir)); if (baseDir == null) { throw new IllegalArgumentException( String.format(ERR_RESOLVE_BAGURI + "base directory was null", bagUri, "null")); final Path originalDir = baseDir; final Path normalizedDir = baseDir.normalize(); if (normalizedDir == null) { throw new RuntimeException(String.format(ERR_RESOLVE_BAGURI + "failed to normalize the base directory.", bagUri, originalDir)); final Path bagPath = Paths.get(bagUri.getAuthority(), bagUri.getPath()); return normalizedDir.resolve(bagPath); |
Path | resolveForSymbolic(final Path path) resolve For Symbolic if (Files.isSymbolicLink(path)) { final Path simLink = Files.readSymbolicLink(path); if (!simLink.isAbsolute()) { final Path symLinkParent = path.toAbsolutePath().getParent(); return symLinkParent.resolve(simLink); return simLink; return path; |