Here you can find the source of ip2Int(String addr)
Parameter | Description |
---|---|
addr | a parameter |
public static long ip2Int(String addr)
//package com.java2s; public class Main { /**/*ww w . j a v a 2s. co m*/ * @param addr * @return */ public static long ip2Int(String addr) { String[] addrArray = addr.split("\\."); long num = 0; for (int i = 0; i < addrArray.length; i++) { num += ((Integer.parseInt(addrArray[i]) % 256 * Math.pow(256, 3 - i))); } return num; } }