ParseURL

try {
    URL url = new URL("http://hostname:80/index.html#_top_");

    String protocol = url.getProtocol();    // http
    String host = url.getHost();            // hostname
    int port = url.getPort();               // 80
    String file = url.getFile();            // index.html
    String ref = url.getRef();              // _top_
} catch (MalformedURLException e) {
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.