Combine paths using path resolution in Java
Description
The following code shows how to combine paths using path resolution.
Example
import java.nio.file.Path;
import java.nio.file.Paths;
//from w w w . jav a 2 s .c om
public class Main {
public static void main(String[] args) {
Path rootPath = Paths.get("c:/home/docs");
System.out.println(rootPath);
Path partialPath = Paths.get("users.txt");
System.out.println(partialPath);
Path resolvedPath = rootPath.resolve(partialPath);
System.out.println(resolvedPath);
}
}
The code above generates the following result.