In my program a user enters a url string, say
http://www.engineering.uiowa.edu/~hawkeng//fall01/graphics/potato.gif
how would I get the IP address of this url? I tried using
InetAddress address = InetAddress.getByName(urlStr);
but the result always comes back null. What is the proper way to get the IP address?
Try this:
InetAddress address = InetAddress.getByName(new URL(urlString).getHost());
To get the raw IP:
String ip = address.getHostAddress();