Java Utililty Methods Path Relative nio

List of utility methods to do Path Relative nio

Description

The list of methods to do Path Relative nio are organized into topic(s).

Method

PathresolveRelative(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);
PathresolveRelativePath(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) {
...
StringresolveRelativeRemotePath(Path root, Path file)
resolve Relative Remote Path
Path relPath = root.relativize(file);
return relPath.toString().replace(File.separatorChar, '/');
FiletoFileWithAbsolutePath(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); 
StringtryMakeRelative(String rootDir, String path)
Tries to make a path relative to a root directory.
return tryMakeRelative(Paths.get(rootDir), Paths.get(path));