import java.net.*;
publicclass GetURLParts {
publicstaticvoid main(String args[]) {
try {
URL u = new URL("http://www.java2s.com");
System.out.println("The URL is " + u);
System.out.println("The protocol part is " + u.getProtocol());
System.out.println("The host part is " + u.getHost());
System.out.println("The port part is " + u.getPort());
System.out.println("The file part is " + u.getFile());
System.out.println("The ref part is " + u.getRef());
} // end try
catch (MalformedURLException e) {
System.err.println("not a URL I understand.");
}
} // end main
} // end getURLParts