API Overview API Index Package Overview Direct link to this page
JDK 1.6
  java.net. URL View Source
Author(s)
James Gosling
Since
JDK1.0
Version
1.134, 04/14/06
Serial
Hierarchy
 Object
      URL
Implements
 Serializable
Subclasses
Description
publicfinal class URL
  Class URL represents a Uniform Resource Locator, a pointer to a "resource" on the World Wide Web.
See also:   
Constructors
public URL (String spec) throws MalformedURLException
  Creates a URL object from the String representation.
public URL (String protocol, String host, int port, String file) throws MalformedURLException
  Creates a URL object from the specified protocol, host, port number, and file.
public URL (String protocol, String host, int port, String file, URLStreamHandler handler) throws MalformedURLException
  Creates a URL object from the specified protocol, host, port number, file, and handler.
public URL (String protocol, String host, String file) throws MalformedURLException
  Creates a URL from the specified protocol name, host name, and file name.
public URL (URL context, String spec) throws MalformedURLException
  Creates a URL by parsing the given spec within a specified context.
public URL (URL context, String spec, URLStreamHandler handler) throws MalformedURLException
  Creates a URL by parsing the given spec with the specified handler within a specified context.
Methods
Hide/Show inherited methods
public boolean equals (Object obj)
  Compares this URL for equality with another object.
public String getAuthority ()
  Gets the authority part of this URL.
publicfinal Object getContent () throws IOException
  Gets the contents of this URL.
publicfinal Object getContent (Class classes) throws IOException
  Gets the contents of this URL.
public int getDefaultPort ()
  Gets the default port number of the protocol associated with this URL.
public String getFile ()
  Gets the file name of this URL.
public String getHost ()
  Gets the host name of this URL, if applicable.
public String getPath ()
  Gets the path part of this URL.
public int getPort ()
  Gets the port number of this URL.
public String getProtocol ()
  Gets the protocol name of this URL.
public String getQuery ()
  Gets the query part of this URL.
public String getRef ()
  Gets the anchor (also known as the "reference") of this URL.
pack-privatestatic URLStreamHandler getURLStreamHandler (String protocol)
  Returns the Stream Handler.
public String getUserInfo ()
  Gets the userInfo part of this URL.
publicsynchronized int hashCode ()
  Creates an integer suitable for hash table indexing.
public URLConnection openConnection () throws IOException
  Returns a URLConnection object that represents a connection to the remote object referred to by the URL.
public URLConnection openConnection (Proxy proxy) throws IOException
  Same as openConnection(), except that the connection will be made through the specified proxy; Protocol handlers that do not support proxing will ignore the proxy parameter and make a normal connection.
publicfinal InputStream openStream () throws IOException
  Opens a connection to this URL and returns an InputStream for reading from that connection.
public boolean sameFile (URL other)
  Compares two URLs, excluding the fragment component.
protected void set (String protocol, String host, int port, String file, String ref)
  Sets the fields of the URL.
protected void set (String protocol, String host, int port, String authority, String userInfo, String path, String query, String ref)
  Sets the specified 8 fields of the URL.
publicstatic void setURLStreamHandlerFactory (URLStreamHandlerFactory fac)
  Sets an application's URLStreamHandlerFactory.
public String toExternalForm ()
  Constructs a string representation of this URL.
public String toString ()
  Constructs a string representation of this URL.
public URI toURI () throws URISyntaxException
  Returns a URI equivalent to this URL.
Fields
Hide/Show inherited fields
pack-privatestatic URLStreamHandlerFactory factory
The URLStreamHandler factory.
pack-privatetransient URLStreamHandler handler
The URLStreamHandler for this URL.
pack-privatestatic Hashtable handlers
A table of protocol handlers.
pack-privatetransient InetAddress hostAddress
  The host's IP address, used in equals and hashCode.
pack-privatefinalstatic long serialVersionUID = "-7627629688361524110"
Nested Classes
Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar