URIUtil { public static String getSndDomainFromUrl(String url) { if (url == null) { return null; } try { final String domain = URI.create(url).getHost(); if (domain != null) { return getSndDomain(domain); } } catch (IllegalArgumentException e) { } logger.debug("The url={} isn't valid, skipping it", url); return null; }  static String getSndDomainFromUrl(String url); static String getSndDomain(String domain);  }
@Test public void testURL() throws Exception { final String s1 = "http: final String s2 = "http: assertEquals("dbpedia.org", URIUtil.getSndDomainFromUrl(s1)); assertEquals("dbpedia.org", URIUtil.getSndDomainFromUrl(s2)); }