Java tutorial
//package com.java2s; /* it under the terms of the GNU General Public License as published by */ public class Main { public static String getDomainFromUri(String domain) { if (domain.indexOf("//") > -1) domain = domain.substring(domain.indexOf("//") + 2); if (domain.endsWith("/")) domain = domain.substring(0, domain.indexOf("/")); if (domain.contains(":")) domain = domain.substring(0, domain.indexOf(":")); return domain; } }