Here you can find the source of getAbsoluteURL(String relativeURL, String baseURL)
private static String getAbsoluteURL(String relativeURL, String baseURL) throws MalformedURLException
//package com.java2s; //License from project: Open Source License import java.net.MalformedURLException; import java.net.URL; public class Main { private static String getAbsoluteURL(String relativeURL, String baseURL) throws MalformedURLException { if (relativeURL.equals("")) { return ""; } else {// ww w .j a v a 2 s . c o m URL url; // convert link to url, assume absolute url then default to relative url with base url of http://m.facebook.com try { url = new URL(relativeURL); } catch (Exception e) { // maybe its not a relative url try { url = new URL(new URL(baseURL), relativeURL); } catch (Exception e2) { // this isn't really an html link...its something like an email or a telephone link, just return null string return ""; } } return url.toString(); } } }