Java Utililty Methods URI to Relative URI

List of utility methods to do URI to Relative URI

Description

The list of methods to do URI to Relative URI are organized into topic(s).

Method

StringresolveUri(URI base, String rel)
resolve Uri
try {
    URI relUri = new URI(rel);
    if (relUri.isAbsolute()) {
        return rel;
} catch (URISyntaxException e) {
String res;
...
URIresolveUri(URI baseUri, String resourceUriStr)
resolve Uri
URI targetUri = null;
if (baseUri.toString().startsWith("jar:")) {
    URI temp = new URI(resourceUriStr);
    if (temp.isAbsolute()) {
        targetUri = temp;
    } else {
        URL targetUrl = new URL(baseUri.toURL(), resourceUriStr);
        targetUri = targetUrl.toURI();
...
URIresolveUri(URI baseUri, URI requestedUri, URI matchedUri)
resolve Uri
String relativePath = requestedUri.getPath().substring(matchedUri.getPath().length());
String result = baseUri.toString() + relativePath;
if (requestedUri.getQuery() != null) {
    result += "?" + requestedUri.getQuery();
return URI.create(result);