Here you can find the source of getBaseUrl(String pageUrl)
public static String getBaseUrl(String pageUrl)
//package com.java2s; public class Main { public static String getBaseUrl(String pageUrl) { try {//from w ww . j av a2 s .co m if (!pageUrl.contains("://")) { pageUrl = "http://" + pageUrl; } int end = pageUrl.indexOf("/", pageUrl.indexOf("://") + 4); return pageUrl.substring(0, end); } catch (Exception e) { } return null; } }