Revision as of 04:40, 23 November 2010 by Han84 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
public static long convertIpToLong(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)));
	}
	return num;
}


Back to JavaHowTo

Alumni Liaison

Followed her dream after having raised her family.

Ruth Enoch, PhD Mathematics