Java Path check if one Path object ends with another Path object
import java.nio.file.Path; import java.nio.file.Paths; public class Main { public static void main(String[] args) { Path p1 = Paths.get("C:\\myData\\Main.java"); Path p2 = Paths.get("C:\\MyData\\main.java"); Path p3 = Paths.get("C:\\myData\\..\\myData\\Main.java"); boolean b1 = p1.endsWith(p2); System.out.println(b1);//from www.j a va 2 s . co m boolean b2 = p1.endsWith(p3); System.out.println(b2); } }