//knowing IPAddress of a website

import java.io.*;

import java.net.*;

class Address

{

public static void main(String args[]) throws IOException

{

//accept the name of the website from keyboard

Buffereder br = new BufferedReader (new InputStreamReader(System.in));

System.out.print(“Enter the name of the website”);

String site = br.readLine();

try{

//getByName() method accept site name and returns it’s ip address

InetAddress ip = InetAddress.getByName(site);

System.out.println(“The IP Address is:  ” + ip);

}catch(UnknownHostException ue)

{

System.out.println(“website not found”);

}

}

}

 

OUTPUT:

c:\>javac Address.java

c:\>java Address

Enter the name of the website: http://www.yahoo.com

The IP Address is:www.yahoo.com/106.10.138.240

Advertisements