URLStreamHandler

public abstract class URLStreamHandler extends Object

The abstract class URLStreamHandler is the base for all classes which can handle the communication with a URL object over a particular protocol type.

Public Constructor Summary

Protected Method Summary

boolean
equals(URL a, URL b)
Returns true if a and b have the same protocol, host, port, file, and reference.
int
getDefaultPort()
Returns the default port of the protocol used by the handled URL.
InetAddress
getHostAddress(URL url)
Returns the host address of url.
int
hashCode(URL url)
Returns the hash code of url.
boolean
hostsEqual(URL a, URL b)
Returns true if the hosts of a and b are equal.
abstract URLConnection
openConnection(URL u)
Establishes a new connection to the resource specified by the URL u.
URLConnection
openConnection(URL u, Proxy proxy)
Establishes a new connection to the resource specified by the URL u using the given proxy.
void
parseURL(URL url, String spec, int start, int end)
Parses the clear text URL in str into a URL object.
boolean
sameFile(URL a, URL b)
Returns true if a and b have the same protocol, host, port and file.
void
setURL(URL u, String protocol, String host, int port, String file, String ref)
This method was deprecated. Use setURL(URL, String String, int, String, String, String, String, String) instead.
void
setURL(URL u, String protocol, String host, int port, String authority, String userInfo, String path, String query, String ref)
Sets the fields of the URL u to the values of the supplied arguments.
String
toExternalForm(URL url)
Returns the clear text representation of a given URL using HTTP format.

Inherited Method Summary

Public Constructors

public URLStreamHandler ()

Protected Methods

protected boolean equals (URL a, URL b)

Returns true if a and b have the same protocol, host, port, file, and reference.

Parameters
a
b

protected int getDefaultPort ()

Returns the default port of the protocol used by the handled URL. The default implementation always returns -1.

protected InetAddress getHostAddress (URL url)

Returns the host address of url.

Parameters
url

protected int hashCode (URL url)

Returns the hash code of url.

Parameters
url

protected boolean hostsEqual (URL a, URL b)

Returns true if the hosts of a and b are equal.

Parameters
a
b

protected abstract URLConnection openConnection (URL u)

Establishes a new connection to the resource specified by the URL u. Since different protocols also have unique ways of connecting, it must be overwritten by the subclass.

Parameters
u the URL to the resource where a connection has to be opened.
Returns
  • the opened URLConnection to the specified resource.
Throws
IOException if an I/O error occurs during opening the connection.

protected URLConnection openConnection (URL u, Proxy proxy)

Establishes a new connection to the resource specified by the URL u using the given proxy. Since different protocols also have unique ways of connecting, it must be overwritten by the subclass.

Parameters