Click here to Skip to main content
15,885,985 members
Articles / Programming Languages / Java
Tip/Trick

Determine the IP address for any website

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
17 Jul 2011CPOL 28.5K   3   4
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:
Java
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());
      }
   }
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
India India
I am a Java software developer. I like to make new software which can be helpful to people. You may get in touch with me at https://cooltrickshome.blogspot.in

Comments and Discussions

 
QuestionTry this out instead Pin
Member 1362938517-Jan-18 18:59
Member 1362938517-Jan-18 18:59 
GeneralIt shows an exception. Pin
jahart28-Oct-11 22:42
jahart28-Oct-11 22:42 
Generalshould there not be a semi-colon at the end of the import st... Pin
DaveAuld17-Jul-11 8:15
professionalDaveAuld17-Jul-11 8:15 
GeneralRe: I made the changes. Thanks for pointing it out.. Pin
csanuragjain17-Jul-11 22:40
csanuragjain17-Jul-11 22:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.