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

Meet a recent graduate heading to Sweden for a Postdoctorate.

Christine Berkesch