Java IP Address to Long ipToLong(String ip)

Here you can find the source of ipToLong(String ip)

Description

ip To Long

License

Open Source License

Declaration

public static long ipToLong(String ip) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static long ipToLong(String ip) { // TODO: check me
        final String[] ipBytesStr = ip.split("\\.");
        long ipValue = 0;
        for (int i = 0; i < 4; i++) {
            ipValue <<= 8;//  ww w .j  av a 2  s .com
            ipValue |= Integer.parseInt(ipBytesStr[i]);
        }
        return ipValue;
    }
}

Related

  1. ipToLong(final String addr)
  2. ipToLong(String addr)
  3. ipTolong(String address)
  4. ipToLong(String ip)
  5. ipToLong(String ip)
  6. ipToLong(String ip)
  7. ipToLong(String ip)
  8. ipToLong(String ipAddress)
  9. ipToLong(String ipAddress)