I would like to compare two paths in the same workspace folder, and get the relative path between them :
String firPath = "C:/toto/tata/test1/test2/img/1.jpg" // test example
String secPath = "C:/toto/tata/test1/img/1.jpg" // test example
example = "../../img/"
What about added in Java 7 Path.relativize?
Path first = Paths.get(firstPath); Path second = Paths.get(secondPath);
System.out.println(first.relativize(second));
System.out.println(second.relativize(first));