If no such handler is found, the constructor throws a MalformedURLException. The exact protocols that are supported vary from implementation to implementation though http and file are supported pretty much everywhere. The last four are custom protocols defined by Sun and used internally by the JDK and HotJava. There are four constructors in the java.net.URL class. All can throw MalformedURLExceptions.
Most protocols have default ports.
The java.net.URL class has five methods to spilt a URL into its component parts. If a port is not explicitly specified in the URL it's set to -1. If the ref doesn't exist, it's just null, so watch out for NullPointerExceptions. Better yet, test to see that it's non-null before using it. This allows you to download data from the server.