Given two absolute paths, e.g.
/var/data/stuff/xyz.dat /var/data
How can one create a relative path that uses the second path as its base?
If you know the second string is part of the first:
String s1 = "/var/data/stuff/xyz.dat"; String s2 = "/var/data"; String s3 = s1.substring(s2.length());
or if you really want the period at the beginning as in your example:
String s3 = ".".concat(s1.substring(s2.length()));