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. ...

Get Component Development for the Java™ Platform now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.