List of utility methods to do IP Address to Long
long | ipToLong(String ip) ip To Long final String[] ipBytesStr = ip.split("\\."); long ipValue = 0; for (int i = 0; i < 4; i++) { ipValue <<= 8; ipValue |= Integer.parseInt(ipBytesStr[i]); return ipValue; |
long | ipToLong(String ip) ip To Long byte[] address = InetAddress.getByName(ip).getAddress(); long ipnum = 0; for (int i = 0; i < 4; ++i) { long y = address[i]; if (y < 0) { y += 256; ipnum += y << ((3 - i) * 8); ... |
long | ipToLong(String ip) Utility for Ip to Long convrsion long ipAddressinLong = 0; if (ip != null) { String[] ipAddressArray = ip.split("\\."); for (int i = 0; i < ipAddressArray.length; i++) { int power = 3 - i; long ipAddress = Long.parseLong(ipAddressArray[i]); ipAddressinLong += ipAddress * Math.pow(256, power); return ipAddressinLong; |
long | ipToLong(String ipAddress) Convert an IP address to a number String[] atoms = ipAddress.split("\\."); long result = 0; for (int i = 3; i >= 0; i--) { result |= (Long.parseLong(atoms[3 - i]) << (i * 8)); return result & 0xFFFFFFFF; |
Long | ipToLong(String ipAddress) ip To Long Long result = 0L; String[] atoms = ipAddress.split("\\."); if (atoms.length != 4) { return null; for (int i = 3; i >= 0; i--) { result |= (Long.parseLong(atoms[3 - i]) << (i * 8)); return result & 0xFFFFFFFF; |
long[] | ipToLong(String ipStr) Ip converted to type long. long[] ipLongArr = new long[2]; final int leftShift3 = 24; final int leftShift2 = 16; final int leftShift1 = 8; if (ipStr.indexOf(".") >= 0) { String[] ip = ipStr.split("\\."); ipLongArr[1] = (Long.parseLong(ip[0]) << leftShift3) + (Long.parseLong(ip[1]) << leftShift2) + (Long.parseLong(ip[2]) << leftShift1) + Long.parseLong(ip[3]); ... |
long | ipToLong(String sip) ip To Long long[] ip = new long[4]; int[] pos = new int[3]; pos[0] = sip.indexOf("."); ip[0] = Long.parseLong(sip.substring(0, pos[0])); for (int i = 1; i < 3; i++) { pos[i] = sip.indexOf(".", pos[i - 1] + 1); ip[i] = Long.parseLong(sip.substring(pos[i - 1] + 1, pos[i])); if (i == 2) { ... |
long | ipToLong(String strIP) ip To Long int j = 0; int i = 0; long[] ip = new long[4]; int position1 = strIP.indexOf("."); int position2 = strIP.indexOf(".", position1 + 1); int position3 = strIP.indexOf(".", position2 + 1); ip[0] = Long.parseLong(strIP.substring(0, position1)); ip[1] = Long.parseLong(strIP.substring(position1 + 1, position2)); ... |
String | ipv4(long ip) ipv StringBuilder ret = new StringBuilder(); ret.insert(0, ip % 256).insert(0, "."); ip >>= 8; ret.insert(0, ip % 256).insert(0, "."); ip >>= 8; ret.insert(0, ip % 256).insert(0, "."); ip >>= 8; ret.insert(0, ip); ... |
long | ipV4AddressToLong(String ipAddress) Converts an IP address string like 192.168.0.1 to an internal long value byte[] bytes = InetAddress.getByName(ipAddress).getAddress(); return convertByteToLong(bytes); |