|Known Direct Subclasses|
Known Indirect Subclasses
The abstract class
URLConnection is the superclass
of all classes that represent a communications link between the
application and a URL. Instances of this class can be used both to
read from and to write to the resource referenced by the URL. In
general, creating a connection to a URL is a multistep process:
|Manipulate parameters that affect the connection to the remote resource.||Interact with the resource; query header fields and contents.|
- The connection object is created by invoking the
openConnectionmethod on a URL.
- The setup parameters and general request properties are manipulated.
- The actual connection to the remote object is made, using the
- The remote object becomes available. The header fields and the contents of the remote object can be accessed.
The setup parameters are modified using the following methods:
and the general request properties are modified using the method:
Default values for the
UseCaches parameters can be set using the methods
Each of the above
set methods has a corresponding
get method to retrieve the value of the parameter or
general request property. The specific parameters and general
request properties that are applicable are protocol specific.
The following methods are used to access the header fields and the contents after the connection is made to the remote object:
Certain header fields are accessed frequently. The methods:
provide convenient access to these fields. The
getContentType method is used by the
getContent method to determine the type of the remote
object; subclasses may find it convenient to override the
In the common case, all of the pre-connection parameters and
general request properties can be ignored: the pre-connection
parameters and request properties default to sensible values. For
most clients of this interface, there are only two interesting
which are mirrored in the
URL class by convenience methods.
More information on the request properties and header fields of
http connection can be found at:
fileNameMap: In versions prior to JDK 1.1.6, field
URLConnectionwas public. In JDK 1.1.6 and later,
fileNameMapis private; accessor and mutator methods
setFileNameMapare added to access it. This change is also described on the Compatibility page. Invoking the close() methods on the InputStream or OutputStream of an URLConnection after a request may free network resources associated with this instance, unless particular protocol specifications specify different behaviours for it.