65.9K
CodeProject is changing. Read more.
Home

Determine the IP address for any website

starIconstarIconstarIconstarIconstarIcon

5.00/5 (1 vote)

Jul 17, 2011

CPOL
viewsIcon

29464

How to determine the IP address for a website in Java.

You can use Java to determine the IP address of any website. A sample Java program:
import java.net.*;

class Addr
{
   public static void main(String args[])
   {
      try
      {
         InetAddress in=InetAddress.getByName("Enter the website here like www.google.com");
         System.out.println("The ip Address of site is:"+in.getHostAddress());
      }
      catch(Exception e)
      {
System.out.println("Some Exception has occurred with details"+e.getMessage());
      }
   }
}