I need to capture a Url, pass it to a string and then parse it out. Can anyone
help me?
Printable View
I need to capture a Url, pass it to a string and then parse it out. Can anyone
help me?
Hello Dusty:
Just call the toString() method on the URL object to get a String representation.
Then you can do whatever you want to the String:
URL url;
try{
url = "http://www.myserver.com"
}catch(MalformedURLException mue){}
String URLString = url.toString();
Hope this helps.
Tom Duffy
"Dusty" <dkodet@csuchico.edu> wrote:
>
>I need to capture a Url, pass it to a string and then parse it out. Can
anyone
>help me?
Dusty <dkodet@csuchico.edu> wrote in message
news:390a253f$1@news.devx.com...
>
> I need to capture a Url, pass it to a string and then parse it out. Can
anyone
> help me?
I can't guess what you mean by "capturing" a URL. But once you've got it
into a string, use the java.net.URL class to parse it:
import java.net.URL;
URL u = new URL(the string you captured it into);
String protocol = u.getProtocol();
String host = u.getHost();
etc.