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.
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.
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.
InetAddress giriAddress = java.net.InetAddress.getByName("www.girionjava.com");
Then, if you want the IP as a String
String address = giriAddress.getHostAddress();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With