Java URI to Relative URI resolveUri(URI baseUri, URI requestedUri, URI matchedUri)

Here you can find the source of resolveUri(URI baseUri, URI requestedUri, URI matchedUri)

Description

resolve Uri

License

Apache License

Declaration

public static URI resolveUri(URI baseUri, URI requestedUri, URI matchedUri) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.net.URI;

public class Main {
    public static URI resolveUri(URI baseUri, URI requestedUri, URI matchedUri) {
        String relativePath = requestedUri.getPath().substring(matchedUri.getPath().length());
        String result = baseUri.toString() + relativePath;
        if (requestedUri.getQuery() != null) {
            result += "?" + requestedUri.getQuery();
        }/*from   w w w  . j  a va 2 s .  c  o  m*/
        return URI.create(result);
    }
}

Related

  1. resolveURI(File base_dir, URI uri)
  2. resolveURI(final String path)
  3. resolveURI(String uri)
  4. resolveUri(URI base, String rel)
  5. resolveUri(URI baseUri, String resourceUriStr)