Resolve sibling Path : Paths « JDK 7 « Java
- Java
- JDK 7
- Paths
Resolve sibling Path
import java.nio.file.Path;
import java.nio.file.Paths;
public class Test {
public static void main(String[] args) {
Path rootPath = Paths.get("/home/docs");
Path resolvedPath = rootPath.resolve("backup/users.txt");
resolvedPath = rootPath.resolve("tmp/A.mp3");
System.out.println("rootPath: " + rootPath);
System.out.println("resolvedPath: " + resolvedPath);
System.out.println();
resolvedPath = rootPath.resolveSibling("tmp/A.mp3");
System.out.println("rootPath: " + rootPath);
System.out.println("resolvedPath: " + resolvedPath);
}
}
Related examples in the same category