The relativization of the given URI against this URI is computed as follows:
If either this URI or the given URI are opaque, or if the scheme and authority components of the two URIs are not identical, or if the path of this URI is not a prefix of the path of the given URI, then the given URI is returned.
Otherwise a new relative hierarchical URI is constructed with query and fragment components taken from the given URI and with a path component computed by removing this URI's path from the beginning of the given URI's path.
Relativization is the inverse of {@link #resolve(Path) resolution}. This method attempts to construct a {@link #isAbsolute relative} paththat when {@link #resolve(Path) resolved} against this path, yields apath that locates the same file as the given path. For example, on UNIX, if this path is {@code "/a/b"} and the given path is {@code "/a/b/c/d"}then the resulting relative path would be {@code "c/d"}. Where this path and the given path do not have a {@link #getRoot root} component,then a relative path can be constructed. A relative path cannot be constructed if only one of the paths have a root component. Where both paths have a root component then it is implementation dependent if a relative path can be constructed. If this path and the given path are {@link #equals equal} then an empty path is returned.
For any two {@link #normalize normalized} paths p andq, where q does not have a root component,
p.relativize(p.resolve(q)).equals(q)
When symbolic links are supported, then whether the resulting path, when resolved against this path, yields a path that can be used to locate the {@link Files#isSameFile same} file as {@code other} is implementationdependent. For example, if this path is {@code "/a/b"} and the givenpath is {@code "/a/x"} then the resulting relative path may be {@code "../x"}. If {@code "b"} is a symbolic link then is implementationdependent if {@code "a/b/../x"} would locate the same file as {@code "/a/x"}. @param other the path to relativize against this path @return the resulting relative path, or an empty path if both paths areequal @throws IllegalArgumentException if {@code other} is not a {@code Path} that can be relativizedagainst this path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|