@Test public void testIPToInt(){ org.junit.Assert.assertEquals(2130706433,IpUtil.ipToInt("127.0.0.1")); org.junit.Assert.assertEquals(172687420,IpUtil.ipToInt("10.75.0.60")); org.junit.Assert.assertEquals(-1062731519,IpUtil.ipToInt("192.168.1.1")); org.junit.Assert.assertEquals(-1356265022,IpUtil.ipToInt("175.41.9.194")); }
public static int ipToInt(final String addr) { final String[] addressBytes = addr.split("\\."); int ip = 0; for (int i = 0; i < 4; i++) { ip <<= 8; ip |= Integer.parseInt(addressBytes[i]); } return ip; }
IpUtil { public static int ipToInt(final String addr) { final String[] addressBytes = addr.split("\\."); int ip = 0; for (int i = 0; i < 4; i++) { ip <<= 8; ip |= Integer.parseInt(addressBytes[i]); } return ip; } }
IpUtil { public static int ipToInt(final String addr) { final String[] addressBytes = addr.split("\\."); int ip = 0; for (int i = 0; i < 4; i++) { ip <<= 8; ip |= Integer.parseInt(addressBytes[i]); } return ip; }  }
IpUtil { public static int ipToInt(final String addr) { final String[] addressBytes = addr.split("\\."); int ip = 0; for (int i = 0; i < 4; i++) { ip <<= 8; ip |= Integer.parseInt(addressBytes[i]); } return ip; }  static String intToIp(int i); static int ipToInt(final String addr); static long ipToLong(final String addr); static String longToIp(long i); static boolean isIp(String in); static Map<String,String> getLocalIps(); static String getLocalIp(); static String getSingleLocalIp(); static int ramdomAvailablePort(); static boolean availablePort(int port); static void main(String[] args); }
IpUtil { public static int ipToInt(final String addr) { final String[] addressBytes = addr.split("\\."); int ip = 0; for (int i = 0; i < 4; i++) { ip <<= 8; ip |= Integer.parseInt(addressBytes[i]); } return ip; }  static String intToIp(int i); static int ipToInt(final String addr); static long ipToLong(final String addr); static String longToIp(long i); static boolean isIp(String in); static Map<String,String> getLocalIps(); static String getLocalIp(); static String getSingleLocalIp(); static int ramdomAvailablePort(); static boolean availablePort(int port); static void main(String[] args);  }