❮ Previous Next ❯

IP Address

Let’s know how to get the IP Address of a website on Internet by using getByName() method which takes host name as argument and returns InetAddress which is nothing but a IPAddress of that server. Let’s see the following program: import java.io.*;
import java.net.*;
class Address
{
     public static void main(String args[]) throws IOException
     {
BufferedReaderbr=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter a website name");
String s=br.readLine();
try
{
InetAddress i=InetAddress.getByName(s);
System.out.println("the ip address is"+i);
}
catch(UnknownHostException u)
{
System.out.println("website not found");
}
     }
}
Output
enter a website name
www.gmail.com
theip address iswww.gmail.com/74.125.228.246

❮ Previous Next ❯



  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved