Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Java Program to find IP address of Website

In this page we will understand and learn How to get IP Address of any website by using Java programming language. Java Networking API provides the method to know IP address of any website. It is possible to know the IP address of website on Internet with the help of getByName() method of InetAddress class of java.net package. The InetAddress class is used to encapsulate both the numerical IP address and the domain name for that address. The InetAddress also includes the factory method getByaddress(),which takes an IP address and returns an InetAddress object. Either an IP4 or IP6 address can be used.




Let us understand and learn the concept with the fallowing example:

import java.io.*;
import java.net.*;
class InetAdressTest
{
public static void main(String[] args)throws UnknownHostException,IOException

{
BufferedReader br=new BufferedReader(new InputStreadReader(System.in));
System.out.println("enter a website name:");
String website=br.readLine();
try
{
InetAddress ip=InetAddress.getByName(website);
System.out.println(" The IP address is:"+ip);
}
catch(UnknownHostException ue)
{
System.out.println("Website not found");
}
}
}

Output:

I hope you enjoy this page and keep follow my blog for latest updates and share post to your friends through social websites like Facebook,google+,linkedin  etc... also comments about your answers on this concept.








This post first appeared on Learnprogramingbyluckysir, please read the originial post: here

Share the post

Java Program to find IP address of Website

×

Subscribe to Learnprogramingbyluckysir

Get updates delivered right to your inbox!

Thank you for your subscription

×