Java Utililty Methods IP Address to Long

List of utility methods to do IP Address to Long

Description

The list of methods to do IP Address to Long are organized into topic(s).

Method

long[]ipv4CidrToLong(String networkCidr)
Converts / format ie.
String[] strNets = networkCidr.split("/");
return new long[] { ipV4AddressToLong(strNets[0]), convertStrCidrToLong(strNets[1]) };
longipV4ToLong(final String ipAddress)
ip V To Long
long result = 0;
String[] atoms = ipAddress.split("\\.");
for (int i = 3; i >= 0; i--) {
    result |= (Long.parseLong(atoms[3 - i]) << (i * 8));
return result & 0xFFFFFFFF;
longipv4ToLong(final String ipv4)
IPv4 to Long.
if (ipv4 == null) {
    return -1L;
final int length = ipv4.length();
if (length < 7 || length > 15) {
    return -1L;
char[] chars = new char[length + 1];
...
longipV4ToLong(String ip)
ip V To Long
String[] octets = ip.split("\\.");
return (Long.parseLong(octets[0]) << 24) + (Integer.parseInt(octets[1]) << 16)
        + (Integer.parseInt(octets[2]) << 8) + Integer.parseInt(octets[3]);