Here you can find the source of normalizeUrl(String baseUrl, String url)
public static String normalizeUrl(String baseUrl, String url) throws MalformedURLException
//package com.java2s; //License from project: Apache License import java.net.MalformedURLException; import java.net.URL; public class Main { public static String normalizeUrl(String baseUrl, String url) throws MalformedURLException { URL parent = new URL(baseUrl); if (url.startsWith("?")) { return parent.toExternalForm().replace("?" + parent.getQuery(), "") + url; }//w w w . j av a 2s.co m URL spec = new URL(parent, url); return spec.toExternalForm(); } }