Java IP Address to Int ipToInt(String addr)

Here you can find the source of ipToInt(String addr)

Description

ip To Int

License

Open Source License

Declaration

public static Long ipToInt(String addr) 

Method Source Code

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

public class Main {
    public static Long ipToInt(String addr) {
        String[] addrArray = addr.split("\\.");
        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)));
        }//w w  w .  j  a v  a 2 s. c  om
        return num;
    }
}

Related

  1. ip2int(String ip)
  2. ip2Int(String ip)
  3. IP2Int(String ip)
  4. ip2int(String ipAddr)
  5. ipToInt(final String addr)
  6. ipToInt(String address)
  7. ipToInt(String ip)
  8. IpToInt(String strIp)
  9. ipToInteger(String ip)