@Test public void testConvertIPString() throws UnknownHostException { byte[] IPBytes = { (byte) 210, (byte)12, (byte)1, (byte)10 }; assertEquals(InetAddress.getByAddress(IPBytes), UrlUtil.convertIPString("210.12.1.10")); Assert.assertNull(UrlUtil.convertIPString("labo-labo")); }
public static InetAddress convertIPString(String IPString) { try { String[] IPAddress = IPString.split("\\."); byte[] IPBytes = { (byte) Integer.parseInt(IPAddress[0]), (byte) Integer.parseInt(IPAddress[1]), (byte) Integer.parseInt(IPAddress[2]), (byte) Integer.parseInt(IPAddress[3]) }; return InetAddress.getByAddress(IPBytes); } catch (Exception uhe) { _log.error("FAILED to convert IP address [" + IPString + "]", uhe); return null; } }
UrlUtil { public static InetAddress convertIPString(String IPString) { try { String[] IPAddress = IPString.split("\\."); byte[] IPBytes = { (byte) Integer.parseInt(IPAddress[0]), (byte) Integer.parseInt(IPAddress[1]), (byte) Integer.parseInt(IPAddress[2]), (byte) Integer.parseInt(IPAddress[3]) }; return InetAddress.getByAddress(IPBytes); } catch (Exception uhe) { _log.error("FAILED to convert IP address [" + IPString + "]", uhe); return null; } } }
UrlUtil { public static InetAddress convertIPString(String IPString) { try { String[] IPAddress = IPString.split("\\."); byte[] IPBytes = { (byte) Integer.parseInt(IPAddress[0]), (byte) Integer.parseInt(IPAddress[1]), (byte) Integer.parseInt(IPAddress[2]), (byte) Integer.parseInt(IPAddress[3]) }; return InetAddress.getByAddress(IPBytes); } catch (Exception uhe) { _log.error("FAILED to convert IP address [" + IPString + "]", uhe); return null; } } private  UrlUtil(); }
UrlUtil { public static InetAddress convertIPString(String IPString) { try { String[] IPAddress = IPString.split("\\."); byte[] IPBytes = { (byte) Integer.parseInt(IPAddress[0]), (byte) Integer.parseInt(IPAddress[1]), (byte) Integer.parseInt(IPAddress[2]), (byte) Integer.parseInt(IPAddress[3]) }; return InetAddress.getByAddress(IPBytes); } catch (Exception uhe) { _log.error("FAILED to convert IP address [" + IPString + "]", uhe); return null; } } 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 InetAddress convertIPString(String IPString) { try { String[] IPAddress = IPString.split("\\."); byte[] IPBytes = { (byte) Integer.parseInt(IPAddress[0]), (byte) Integer.parseInt(IPAddress[1]), (byte) Integer.parseInt(IPAddress[2]), (byte) Integer.parseInt(IPAddress[3]) }; return InetAddress.getByAddress(IPBytes); } catch (Exception uhe) { _log.error("FAILED to convert IP address [" + IPString + "]", uhe); return null; } } 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();  }