Convert IP Address to Integer Number

Java Code to Convert IP Address to Integer Value

This code will convert the IP Address string to its equivalent decimal value.
//Source code IP Address to Integer

String ip="22.244.24.45";
String[] addrArray = ip.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)));
}


Related Topic PHP Convert IP Address to Int
What are all the Primary Networking Devices
What is Scalar Values Manipulation in Perl Scripting
What is the Difference between i386 and x86-64
Javascript Date Object Constructor with Examples
Java  

nScraps.com © 2011   Privacy Policy  Terms of Service  Feedback