<p>Given two absolute paths, e.g.</p>

<pre><code>/var/data/stuff/xyz.dat
/var/data
</code></pre>

<p>How can one create a relative path that uses the second path as its base? In the example above, the result should be: <code>./stuff/xyz.dat</code></p>

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()));
```
```