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); } }