O'Reilly logo

Component Development for the Java™ Platform by Stuart Dabbs Halloway

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

5.3. Protocol Handlers

In most cases, writing your own custom class loader is overkill, thanks to yet another feature of the ubiquitous URLClassLoader—pluggable URL protocols called protocol handlers. If you look at the code for the java.net.URL class, you will see that it doesn't actually do very much. URL includes code to parse a URL string into its component parts: protocol, host, port, and file. Everything else is delegated to helper classes called protocol handlers, or synonymously, stream handlers. Protocol handlers can be used with any URL, so you can use them for other purposes besides just class loading.

The Java 2 platform comes with several protocol handlers built in, including handlers for the all-important http and file protocols. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required