IpUtils { public static Integer ip2int(String ipAddress) { Inet4Address a; try { a = (Inet4Address) InetAddress.getByName(ipAddress); } catch (UnknownHostException e) { _log.error(ExceptionUtils.errorInfo(e)); return null; } byte[] b = a.getAddress(); return ((b[0] & 0xFF) << 24) | ((b[1] & 0xFF) << 16) | ((b[2] & 0xFF) << 8) | (b[3] & 0xFF); } private  IpUtils(); static boolean checkValid(final String ip); static boolean checkValid2(final String ip); static boolean checkValidV6(final String ip); static String removeTail32(String ip); static String extractDomain(String url); static String getTailFromURL(String url); static long ip2long(String ipAddress); static String long2ip(Long ipAddress); static Integer ip2int(String ipAddress); static Boolean checkIPRange(final String ipAddress, final String range); static String getIPFromURL(String url); static Boolean isReachable(final String ipAddress); static boolean ping(final String ipAddress); static List<String> getCurrentEnvironmentNetworkIps();  }
@Test public void checkIP2IntTest() { Integer ip2int = ip2int("10.1.1.0"); Assert.notNull(ip2int); int ip = ip2int; assertEquals(167837952, ip); assertEquals(0x0A010100, ip); }