Java Path Relative nio resolveRelativePath(String first, String... more)

Here you can find the source of resolveRelativePath(String first, String... more)

Description

resolve Relative Path

License

Apache License

Declaration

private static Path resolveRelativePath(String first, String... more) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
    private static Path resolveRelativePath(String first, String... more) {
        String workingDirName = System.getProperty("user.dir");
        if (workingDirName == null) {
            throw new IllegalStateException("Working directory yet defined");
        }//from w  w w  . j  a  v  a  2 s. c o m
        Path workingDir = Paths.get(workingDirName);
        Path path = workingDir.resolve(first);
        if (more != null) {
            for (String part : more) {
                path = path.resolve(part);
            }
        }
        return path;
    }
}

Related

  1. relativizePath(IPath path, IPath basePath, boolean strict)
  2. relativizePath(Path root, Path child)
  3. relativizePath(String basePath, File toRelativize)
  4. resolvePathIfRelativeTo(File referenceFile, String partialPath)
  5. resolveRelative(Path p, String other)
  6. resolveRelativeRemotePath(Path root, Path file)
  7. toFileWithAbsolutePath(String relativePath)
  8. tryMakeRelative(String rootDir, String path)