The example below parses a URL object.

Java Code:
/ Create a URL object
            url = new URL("http://www.java-forums.org:80/sendmessage.php");
            // Get all components of the URL object
            protocol = url.getProtocol();
            host     = url.getHost();
            port     = url.getPort();
            file     = url.getFile();
            ref      = url.getRef();