Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Jeff Cunningham   on Apr 04 In Java Category.

  
Question Answered By: Silk Choco   on Apr 04

Well ! i have tried the following code snippet using try -catch block statement to get ip address using its name :

try
{
java.net.InetAddress inetAdd =
java.net.InetAddress.getByName("enter the host name");
System.out.println ("IP Address is : " + inetAdd.getHostAddress());
}
catch(catch(java.net.UnknownHostException uhe)
{
//handle exception
}

In catch block, i used user-defined exception to handle the errors. Instead of coding you can also get ip by its name through online sites like http://www.ip-details.com/domain-host-search/ .

Share: 

 
 
Didn't find what you were looking for? Find more on Get IP address by its name. Or get search suggestion and latest updates.


Tagged: