Java IP Address to Long ip2Long(String ip)

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

Description

ip Long

License

Open Source License

Declaration

public static long ip2Long(String ip) 

Method Source Code

//package com.java2s;

public class Main {

    public static long ip2Long(String ip) {
        long ret = 0;
        if (ip == null) {
            return ret;
        }/*from   w ww.j  a  v a 2s.c om*/
        String[] segs = ip.split("\\.");

        for (int i = 0; i < segs.length; i++) {
            long seg = Long.parseLong(segs[i]);
            ret += (seg << ((3 - i) * 8));
        }

        return ret;
    }
}

Related

  1. ip2long(String ip)
  2. ip2Long(String ip)
  3. ip2long(String ip)
  4. ip2long(String ip)
  5. ip2long(String ip)
  6. ip2Long(String ipAddress)
  7. ip2Long(String ipaddress)
  8. ipToLong(byte[] address)
  9. ipToLong(byte[] octets)