DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3

Thread: Url capture

  1. #1
    Dusty Guest

    Url capture


    I need to capture a Url, pass it to a string and then parse it out. Can anyone
    help me?

  2. #2
    Tom Duffy Guest

    Re: Url capture


    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?



  3. #3
    Paul Clapham Guest

    Re: Url capture


    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.




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links