How to get an IP address of a URL using Java
It is often required to know the IP address of a website while building some applications, and it is very simple to know the IP of any URL using the Java.
Java provides a class called
InetAddress that can be used to get the IP.
Here is an example that shows that how we can get the IP address of an URL:
import java.net.InetAddress;
import java.net.UnknownHostException;
public class KnowIP {
public static void main(String[] args) throws UnknownHostException {
InetAddress address=InetAddress.getByName("www.google.com");
String ipAddress=address.getHostAddress();
System.out.println(ipAddress);
}
}
My Daawat
Thanks for your info. I have checked my website ip address from this site WhoisXY.com
ReplyDelete