Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The way the URL, URLStreamHandler, URLConnection, and URLStreamHandlerFactory classes work together
can be confusing. Everything starts with a URL, which represents a
pointer to a particular Internet resource. Each URL specifies the
protocol used to access the resource; typical values for the protocol
include mailto, http, and ftp. When you construct a URL object from the URL’s string
representation, the constructor strips the protocol field and passes it
to the URLStreamHandlerFactory
. The factory’s job is to take the protocol, locate the
right subclass of URLStreamHandler
for the protocol, and create a new instance of that stream handler,
which is stored as a field within the URL object. Each application has at most one
URLStreamHandlerFactory; once the
factory has been installed, attempting to install another will throw an
Error.