| java.lang.Object java.net.URL
URL | final public class URL implements java.io.Serializable(Code) | | An instance of class URL specifies the location of a resource on the world
wide web as specified by RFC 1738.
|
Constructor Summary | |
public | URL(String spec) Constructs a new URL instance by parsing the specification. | public | URL(URL context, String spec) Constructs a new URL by parsing the specification given by
spec and using the context provided by
context . | public | URL(URL context, String spec, URLStreamHandler handler) Constructs a new URL by parsing the specification given by
spec and using the context provided by
context . | public | URL(String protocol, String host, String file) Constructs a new URL instance using the arguments provided. | public | URL(String protocol, String host, int port, String file) Constructs a new URL instance using the arguments provided. | public | URL(String protocol, String host, int port, String file, URLStreamHandler handler) Constructs a new URL instance using the arguments provided. |
Method Summary | |
public boolean | equals(Object o) Compares the argument to the receiver, and answers true if they represent
the same URL. | void | fixURL(boolean fixHost) | public String | getAuthority() Answers the authority component of this URL. | final public Object | getContent() Answers an Object representing the resource referenced by this URL. | final public Object | getContent(Class[] types) Answers an Object representing the resource referenced by this URL. | public int | getDefaultPort() Returns the default port for this URL as defined by the URLStreamHandler. | public String | getFile() Answers the file component of this URL. | public String | getHost() Answers the host component of this URL. | public String | getPath() Answers the path component of this URL. | public int | getPort() Answers the port component of this URL. | public String | getProtocol() Answers the protocol component of this URL. | public String | getQuery() Answers the query component of this URL. | public String | getRef() Answers the reference component of this URL. | public String | getUserInfo() Answers the user info component of this URL. | public int | hashCode() Answers a hash code for this URL object. | public URLConnection | openConnection() Creates a connection to this URL using the appropriate ProtocolHandler. | public URLConnection | openConnection(Proxy proxy) The method is the same as openConnection() except that it
uses the proxy to establish a connection to this URL using
appropriate ProtocolHandler. | final public InputStream | openStream() Answers a stream for reading from this URL. | public boolean | sameFile(URL otherURL) Answers true if the receiver and the argument refer to the same file. | protected void | set(String protocol, String host, int port, String file, String ref) Sets the properties of this URL using the provided arguments. | protected void | set(String protocol, String host, int port, String authority, String userInfo, String path, String query, String ref) Sets the properties of this URL using the provided arguments. | public static synchronized void | setURLStreamHandlerFactory(URLStreamHandlerFactory streamFactory) Sets the URL Stream (protocol) handler factory. | void | setupStreamHandler() Sets the receiver's stream handler to one which is appropriate for its
protocol. | public String | toExternalForm() Create and return the String representation of this URL. | public String | toString() Answers a string containing a concise, human-readable description of the
receiver. | public URI | toURI() |
URL | public URL(URL context, String spec) throws MalformedURLException(Code) | | Constructs a new URL by parsing the specification given by
spec and using the context provided by
context .
The protocol of the specification is obtained by parsing the
spec string.
If the spec does not specify a protocol:
- If the context is
null , then a
MalformedURLException .
- If the context is not
null , then the protocol is
obtained from the context.
If the spec does specify a protocol:
- If the context is
null , or specifies a different
protocol than the spec, the context is ignored.
- If the context is not
null and specifies the same
protocol as the specification, the properties of the new URL
are obtained from the context.
Parameters: context - java.net.URL URL to use as context. Parameters: spec - java.lang.String a URL specification. throws: MalformedURLException - if the spec could not be parsed as an URL. |
URL | public URL(URL context, String spec, URLStreamHandler handler) throws MalformedURLException(Code) | | Constructs a new URL by parsing the specification given by
spec and using the context provided by
context .
If the handler argument is non-null, a security check is made to verify
that user-defined protocol handlers can be specified.
The protocol of the specification is obtained by parsing the
spec string.
If the spec does not specify a protocol:
- If the context is
null , then a
MalformedURLException .
- If the context is not
null , then the protocol is
obtained from the context.
If the spec does specify a protocol:
- If the context is
null , or specifies a different
protocol than the spec, the context is ignored.
- If the context is not
null and specifies the same
protocol as the specification, the properties of the new URL
are obtained from the context.
Parameters: context - java.net.URL URL to use as context. Parameters: spec - java.lang.String a URL specification. Parameters: handler - java.net.URLStreamHandler a URLStreamHandler. throws: MalformedURLException - if the spec could not be parsed as an URL |
URL | public URL(String protocol, String host, String file) throws MalformedURLException(Code) | | Constructs a new URL instance using the arguments provided.
Parameters: protocol - String the protocol for the URL. Parameters: host - String the name of the host. Parameters: file - the name of the resource. throws: MalformedURLException - if the parameters do not represent a valid URL. |
URL | public URL(String protocol, String host, int port, String file) throws MalformedURLException(Code) | | Constructs a new URL instance using the arguments provided.
Parameters: protocol - String the protocol for the URL. Parameters: host - String the name of the host. Parameters: port - int the port number. Parameters: file - String the name of the resource. throws: MalformedURLException - if the parameters do not represent a valid URL. |
URL | public URL(String protocol, String host, int port, String file, URLStreamHandler handler) throws MalformedURLException(Code) | | Constructs a new URL instance using the arguments provided.
If the handler argument is non-null, a security check is made to verify
that user-defined protocol handlers can be specified.
Parameters: protocol - the protocol for the URL. Parameters: host - the name of the host. Parameters: port - the port number. Parameters: file - the name of the resource. Parameters: handler - the stream handler that this URL uses. throws: MalformedURLException - if the parameters do not represent an URL. |
equals | public boolean equals(Object o)(Code) | | Compares the argument to the receiver, and answers true if they represent
the same URL. Two URLs are equal if they have the same file, host, port,
protocol, and reference components.
Parameters: o - the object to compare with this URL. true if the object is the same as this URL,false otherwise. See Also: URL.hashCode() |
fixURL | void fixURL(boolean fixHost)(Code) | | |
getAuthority | public String getAuthority()(Code) | | Answers the authority component of this URL.
the receiver's authority. |
getContent | final public Object getContent() throws IOException(Code) | | Answers an Object representing the resource referenced by this URL.
The object of the resource pointed by this URL. throws: IOException - If an error occurred obtaining the content. |
getContent | final public Object getContent(Class[] types) throws IOException(Code) | | Answers an Object representing the resource referenced by this URL.
Parameters: types - The list of acceptable content types The object of the resource pointed by this URL, or null if thecontent does not match a specified content type. throws: IOException - If an error occurred obtaining the content. |
getDefaultPort | public int getDefaultPort()(Code) | | Returns the default port for this URL as defined by the URLStreamHandler.
the default port for this URL See Also: URLStreamHandler.getDefaultPort |
getFile | public String getFile()(Code) | | Answers the file component of this URL.
the receiver's file. |
getHost | public String getHost()(Code) | | Answers the host component of this URL.
the receiver's host. |
getPath | public String getPath()(Code) | | Answers the path component of this URL.
the receiver's path. |
getPort | public int getPort()(Code) | | Answers the port component of this URL.
the receiver's port. |
getProtocol | public String getProtocol()(Code) | | Answers the protocol component of this URL.
the receiver's protocol. |
getQuery | public String getQuery()(Code) | | Answers the query component of this URL.
the receiver's query. |
getRef | public String getRef()(Code) | | Answers the reference component of this URL.
the receiver's reference component. |
getUserInfo | public String getUserInfo()(Code) | | Answers the user info component of this URL.
the receiver's user info. |
hashCode | public int hashCode()(Code) | | Answers a hash code for this URL object.
the hashcode for hashtable indexing |
openConnection | public URLConnection openConnection() throws IOException(Code) | | Creates a connection to this URL using the appropriate ProtocolHandler.
The connection to this URL. throws: IOException - if the connection to the URL is not possible. |
openConnection | public URLConnection openConnection(Proxy proxy) throws IOException(Code) | | The method is the same as openConnection() except that it
uses the proxy to establish a connection to this URL using
appropriate ProtocolHandler.
The connection to this URL. Parameters: proxy - the proxy which is used to make the connection exception: IOException - thrown if an IO error occurs during connectionestablishment exception: SecurityException - thrown if a security manager is installed and it deniesthe permission to connect to the proxy. exception: IllegalArgumentException - thrown if the proxy is null or of an invalid type. exception: UnsupportedOperationException - thrown if the protocol handler doesn't support thismethod. |
sameFile | public boolean sameFile(URL otherURL)(Code) | | Answers true if the receiver and the argument refer to the same file. All
components except the reference are compared.
Parameters: otherURL - URL to compare against. true if the same resource, false otherwise |
set | protected void set(String protocol, String host, int port, String file, String ref)(Code) | | Sets the properties of this URL using the provided arguments. This method
is used both within this class and by the URLStreamHandler
code.
Parameters: protocol - the new protocol. Parameters: host - the new host name. Parameters: port - the new port number. Parameters: file - the new file component. Parameters: ref - the new reference. See Also: URL See Also: URLStreamHandler |
set | protected void set(String protocol, String host, int port, String authority, String userInfo, String path, String query, String ref)(Code) | | Sets the properties of this URL using the provided arguments. This method
is used both within this class and by the URLStreamHandler
code.
Parameters: protocol - the new protocol. Parameters: host - the new host name. Parameters: port - the new port number. Parameters: authority - the new authority. Parameters: userInfo - the new user info. Parameters: path - the new path component. Parameters: query - the new query. Parameters: ref - the new reference. See Also: URL See Also: URLStreamHandler |
setURLStreamHandlerFactory | public static synchronized void setURLStreamHandlerFactory(URLStreamHandlerFactory streamFactory)(Code) | | Sets the URL Stream (protocol) handler factory. This method can be
invoked only once during an application's lifetime.
A security check is performed to verify that the current Policy allows
the stream handler factory to be set.
Parameters: streamFactory - URLStreamHandlerFactory The factory to use for finding streamhandlers. |
setupStreamHandler | void setupStreamHandler()(Code) | | Sets the receiver's stream handler to one which is appropriate for its
protocol. Throws a MalformedURLException if no reasonable handler is
available.
Note that this will overwrite any existing stream handler with the new
one. Senders must check if the strmHandler is null before calling the
method if they do not want this behavior (a speed optimization).
|
toString | public String toString()(Code) | | Answers a string containing a concise, human-readable description of the
receiver.
a printable representation for the receiver. |
|
|