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?
When using java.net.URI.relativize you should be aware of Java bug: JDK-6226081 (URI should be able to relativize paths with partial roots)
At the moment, the
relativize()
method ofURI
will only relativize URIs when one is a prefix of the other.
Which essentially means java.net.URI.relativize
will not create ".."'s for you.