Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the IP address from the Domain Name in Java?

Tags:

I am writing an application where I need the IP address. I have a domain name and I would like to know how to get the IP address from it. For example, "www.girionjava.com". How could I get the IP address of this website by programming in Java? Thanks.

like image 378
giri Avatar asked Mar 17 '10 13:03

giri


People also ask

How do I find my Java IP address?

In Java, you can use InetAddress. getLocalHost() to get the Ip Address of the current Server running the Java app and InetAddress. getHostName() to get Hostname of the current Server name.

What is IP address find IP address of given website using Java program?

To find public IP, use http://bot.whatismyipaddress.com. It is an online utility, to find the system's public IP. Open the URL, read a line and print the line.


1 Answers

InetAddress giriAddress = java.net.InetAddress.getByName("www.girionjava.com"); 

Then, if you want the IP as a String

String address = giriAddress.getHostAddress(); 
like image 159
Powerlord Avatar answered Nov 22 '22 08:11

Powerlord