Here you can find the source of resolveUri(URI base, String rel)
public static String resolveUri(URI base, String rel)
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URISyntaxException; import java.net.URLEncoder; public class Main { public static String resolveUri(URI base, String rel) { // FIXME/* w w w . j a v a 2 s . c o m*/ try { URI relUri = new URI(rel); if (relUri.isAbsolute()) { return rel; } } catch (URISyntaxException e) { // silent } String res; try { res = resolveRelativeURI(base, rel); new URI(res); return res; } catch (Exception ex) { //try encoding String encodedRel; try { encodedRel = URLEncoder.encode(rel, "UTF-8"); } catch (UnsupportedEncodingException e) { //silent return ""; } return resolveRelativeURI(base, encodedRel); } } private static String resolveRelativeURI(URI base, String rel) { if (base.getFragment() != null) { return base + rel; } return base.resolve(rel).toString(); } }