The example below parses a URL object.
/ 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();