JAVA-MANI.BLOGSPOT.COM
Friday, September 19, 2008
import java.net.InetAddress;
import java.net.UnknownHostException;

public class IPAddressExample
{
public static void main(String[] args)
{
try
{
InetAddress address = InetAddress.getLocalHost();

byte[] ip = address.getAddress();

int i = 4;
String ipAddress = "";
for (byte b : ip)
{
ipAddress += (b & 0xFF);
if (--i > 0)
{
ipAddress += ".";
}
}

System.out.println(ipAddress);
} catch (UnknownHostException e)
{
e.printStackTrace();
}
}
}

0 comments:

SUBSCRIBE VIA eMAIL

Enter your email address:

Delivered by FeedBurner

Recent Posts

Firefox 3

Counter

internet companies

Live Traffic Map

Subscribe Now