Java tutorial
//package com.java2s; import java.net.URI; import java.net.URISyntaxException; public class Main { public static String getDomainName(String url) { String domain = ""; URI uri; try { uri = new URI(url); domain = uri.getHost(); } catch (URISyntaxException e) { e.printStackTrace(); } return domain.startsWith("www.") ? domain.substring(4) : domain; } }