@Test public void testGetHostname() { assertEquals("www.ideyatech.com", UrlUtil.getHostname("http: assertEquals("www.ideyatech.com", UrlUtil.getHostname("http: assertEquals("www.ideyatech.com", UrlUtil.getHostname("http: assertEquals("www.ideyatech.com", UrlUtil.getHostname("www.ideyatech.com")); assertEquals("www.ideyatech.com", UrlUtil.getHostname("www.ideyatech.com/")); assertEquals("www.ideyatech.com", UrlUtil.getHostname("www.ideyatech.com/test/original")); }
public static String getHostname(String url) { int startIndex = 0; if (hasProtocol(url)) { startIndex = url.lastIndexOf(": } int endIndex = url.indexOf("/", startIndex); if (endIndex < 0) endIndex = url.length(); return url.substring(startIndex, endIndex); }
UrlUtil { public static String getHostname(String url) { int startIndex = 0; if (hasProtocol(url)) { startIndex = url.lastIndexOf(": } int endIndex = url.indexOf("/", startIndex); if (endIndex < 0) endIndex = url.length(); return url.substring(startIndex, endIndex); } }
UrlUtil { public static String getHostname(String url) { int startIndex = 0; if (hasProtocol(url)) { startIndex = url.lastIndexOf(": } int endIndex = url.indexOf("/", startIndex); if (endIndex < 0) endIndex = url.length(); return url.substring(startIndex, endIndex); } private  UrlUtil(); }
UrlUtil { public static String getHostname(String url) { int startIndex = 0; if (hasProtocol(url)) { startIndex = url.lastIndexOf(": } int endIndex = url.indexOf("/", startIndex); if (endIndex < 0) endIndex = url.length(); return url.substring(startIndex, endIndex); } private  UrlUtil(); static boolean hasProtocol(String url); static String ensureProtocol(String url, String protocol); static String ensureProtocol(String url); static String getHostname(String url); static String getRefererURI(HttpServletRequest request); static String getProtocol(String url); static String getAbsoluteUrl(String url, String src); static String getURLParam(String url, String paramName); static InetAddress convertIPString(String IPString); static List<String> getEndPoints(); }
UrlUtil { public static String getHostname(String url) { int startIndex = 0; if (hasProtocol(url)) { startIndex = url.lastIndexOf(": } int endIndex = url.indexOf("/", startIndex); if (endIndex < 0) endIndex = url.length(); return url.substring(startIndex, endIndex); } private  UrlUtil(); static boolean hasProtocol(String url); static String ensureProtocol(String url, String protocol); static String ensureProtocol(String url); static String getHostname(String url); static String getRefererURI(HttpServletRequest request); static String getProtocol(String url); static String getAbsoluteUrl(String url, String src); static String getURLParam(String url, String paramName); static InetAddress convertIPString(String IPString); static List<String> getEndPoints();  }