aturetsky
asked on
getting host from URL string
I have a url string and I'd like to get the host out of it.
Now, I know I can just do:
URL url = new URL("http:///whatever.com/whatever?whatever=whatever");
String host = url.getHost();
But must I really instatiate a URL every time? Is there some kind of a static utility class that would do this without the need to do "new URL" ? For the purposes of this question, assume that I don't want to be manually parsing the string using a regex or a substring.
Now, I know I can just do:
URL url = new URL("http:///whatever.com/whatever?whatever=whatever");
String host = url.getHost();
But must I really instatiate a URL every time? Is there some kind of a static utility class that would do this without the need to do "new URL" ? For the purposes of this question, assume that I don't want to be manually parsing the string using a regex or a substring.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:-)
ASKER