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();
1.4m articles
1.4m replys
5 comments
57.0k users