Wednesday, 6 March 2013

Program to obtain the IP address of a given website address.

import java.net.*;
import java.util.*;
class Ip
{
public static void main(String args[])
{
try{

Scanner sc=new Scanner(System.in);
System.out.println("Enter the url");

String url=sc.next();

//String url=args[0];                   //By Command line

InetAddress i=InetAddress.getByName(url);
System.out.println("Host address:" +i.getHostAddress());
System.out.println("Host name   :"+i.getHostName());
}
catch(Exception e)
{}
}
}

No comments:

Post a Comment