List of utility methods to do IP Address to Long
long | convertIPS2Long(String ip) convert IPS Long char[] c = ip.toCharArray(); byte[] b = { 0, 0, 0, 0 }; for (int i = 0, j = 0; i < c.length;) { int d = (byte) (c[i] - '0'); switch (c[i++]) { case '.': ++j; break; ... |
long | convertIpString2Long(String IP) Parse the long number of IPv4 address from dot-separated string String[] addrArray = IP.split("\\."); if (addrArray.length != 4) { throw new NumberFormatException("Invalid IP string format: " + IP); long num = 0; for (int i = 0; i < addrArray.length; i++) { int power = 3 - i; num += ((Integer.parseInt(addrArray[i]) % 256 * Math.pow(256, power))); ... |
long | ip2Long(final String ip) ip Long final String[] tokens = ip.split("[.]"); assert tokens.length == 4; long result = 0; for (int i = 0; i < tokens.length; i++) { try { result = result << 8 | Integer.parseInt(tokens[i]); } catch (final NumberFormatException e) { throw new RuntimeException("Incorrect number", e); ... |
long | ip2long(String ip) iplong String[] ips = ip.split("[.]"); long num = 16777216L * Long.parseLong(ips[0]) + 65536L * Long.parseLong(ips[1]) + 256 * Long.parseLong(ips[2]) + Long.parseLong(ips[3]); return num; |
long | ip2long(String ip) iplong String[] parts = ip.split("\\."); long result = 0; int power = 0; if (parts.length != 4) { throw new IllegalArgumentException("Invalid IP format"); for (int i = parts.length; i > 0; i--) { int parseInt = Integer.parseInt(parts[i - 1]); ... |
Long | ip2long(String ip) iplong String[] arrStr = ip.split("\\."); if (arrStr.length != 4) throw new IllegalArgumentException("Wrong IP address"); Long longIP = Long.parseLong(arrStr[0]) * 256 * 256 * 256 + Long.parseLong(arrStr[1]) * 256 * 256 + Long.parseLong(arrStr[2]) * 256 + Long.parseLong(arrStr[3]); return longIP; |
long | ip2Long(String ip) ip Long if (ip == null) return 0; if (ip.startsWith("/")) ip = ip.substring(1); int i = ip.indexOf(":"); if (i > 0) ip = ip.substring(0, i); String[] strs = ip.split("\\."); ... |
long | ip2long(String ip) iplong long ipNumber = 0; String[] ips = ip.split("[.]"); for (int i = 0; i < 4; ++i) { ipNumber = ipNumber << 8 | Integer.parseInt(ips[i]); return ipNumber; |
long | ip2long(String ip) Convert dotted IP to long String[] part = ip.split("\\."); long num = 0; for (int i = 0; i < part.length; i++) { int power = 3 - i; num += ((Integer.parseInt(part[i]) % 256 * Math.pow(256, power))); return num; |
long | ip2long(String ip) string ip to long ip String[] p = ip.split("\\."); if (p.length != 4) return 0; int p1 = ((Integer.valueOf(p[0]) << 24) & 0xFF000000); int p2 = ((Integer.valueOf(p[1]) << 16) & 0x00FF0000); int p3 = ((Integer.valueOf(p[2]) << 8) & 0x0000FF00); int p4 = ((Integer.valueOf(p[3]) << 0) & 0x000000FF); return ((p1 | p2 | p3 | p4) & 0xFFFFFFFFL); ... |