List of utility methods to do Path Resolve nio
int | resolveMaxStep(String rootPath) resolve Max Step int maxStep = 0; while (Files.exists(Paths.get(rootPath + File.separator + String.valueOf(maxStep + 1)))) { maxStep++; return maxStep; |
Path | resolvePath(final Path baseDirPath, final Path userPath) Resolves an untrusted user-specified path against the API's base directory. final Path resolvedPath = baseDirPath.resolve(userPath).normalize(); if (!baseDirPath.isAbsolute()) { throw new IllegalArgumentException("Base path must be absolute"); if (userPath.isAbsolute()) { throw new IllegalArgumentException("User path must be relative"); if (!resolvedPath.startsWith(baseDirPath)) { ... |
LinkedList | resolvePathElements(final Path path) resolve Path Elements final LinkedList<String> elements = Lists.newLinkedList(); final String[] elementArray = path.toString().split(Pattern.quote(path.getFileSystem().getSeparator())); for (final String element : elementArray) { if (!Strings.isNullOrEmpty(element)) { elements.add(element); return elements; ... |
File | resolveSymLink(Path link) resolve Sym Link return Files.readSymbolicLink(link).toFile();
|