Partial comparing is achievable via the Path.startsWith() and Path.endsWith() methods. Using these methods, we can test whether the current path starts/ends with the given path:
boolean sw = path1.startsWith("/learning/packt"); // true
boolean ew = path1.endsWith("JavaModernChallenge.pdf"); // true