Monday, May 3, 2010

Q. WAP to obtain IP address of localhost and any well known website

import java.net.*;
import java.io.*;

class prg1{
static void p(String s)
{
System.out.println(s);
}

public static void main(String s[]) throws UnknownHostException, IOException
{
InetAddresss i,o[];
i=InetAddress.getLocalHost();
p("local host"+i);
i=InetAddress.getByName("10.0.56.80");
p("10.0.56.80"+i);
o=InetAddress.getAllByName("www.ndtv.com");
for(int j=0;j{
p("ndtv ip address"+j+" "+o[j]);
}
}
}

No comments:

Post a Comment