List of utility methods to do Path Relative nio
Path | resolveRelative(Path p, String other) Convenience method to ensure that "other" is not an absolute path. Path op = Paths.get(other); if (op.isAbsolute()) { throw new IllegalArgumentException(other + " cannot be an absolute path!"); return p.resolve(op); |
Path | resolveRelativePath(String first, String... more) resolve Relative Path String workingDirName = System.getProperty("user.dir"); if (workingDirName == null) { throw new IllegalStateException("Working directory yet defined"); Path workingDir = Paths.get(workingDirName); Path path = workingDir.resolve(first); if (more != null) { for (String part : more) { ... |
String | resolveRelativeRemotePath(Path root, Path file) resolve Relative Remote Path Path relPath = root.relativize(file); return relPath.toString().replace(File.separatorChar, '/'); |
File | toFileWithAbsolutePath(String relativePath) Upstream, based on branch 'master' of git@github.com:adaussy/EMFCompareGitPGM.git Returns, from a relative path, the corresponding file with an absolute path. return toFileWithAbsolutePath(System.getProperty("user.dir"), relativePath); |
String | tryMakeRelative(String rootDir, String path) Tries to make a path relative to a root directory. return tryMakeRelative(Paths.get(rootDir), Paths.get(path));
|