|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--java.net.URL
Class URL represents a Uniform Reference Locator -- a reference to an object on the World Wide Web. This is a constant object, once it is created, its fields cannot be changed.
| Constructor Summary | |
URL(String spec)
Creates a URL from the unparsed absolute URL. |
|
URL(String protocol,
String host,
int port,
String file)
Creates an absolute URL from the specified protocol, host, port and file. |
|
URL(String protocol,
String host,
String file)
Creates an absolute URL from the specified protocol, host, and file. |
|
URL(URL context,
String spec)
Creates a URL from the unparsed URL in the specified context.If spec is an absolute URL it is used as is. |
|
| Method Summary | |
boolean |
equals(Object obj)
Compares two URLs. |
Object |
getContent()
Gets the contents from this opened connection. |
String |
getFile()
Gets the file name. |
String |
getHost()
Gets the host name. |
int |
getPort()
Gets the port number. |
String |
getProtocol()
Gets the protocol name. |
String |
getRef()
Gets the ref. |
int |
hashCode()
Creates an integer suitable for hash table indexing. |
URLConnection |
openConnection()
Creates (if not already in existance) a URLConnection object that contains a connection to the remote object referred to by the URL. |
InputStream |
openStream()
Opens an input stream. |
boolean |
sameFile(URL other)
Compares two URLs, excluding the "ref" fields: sameFile is true if the true references the same remote object, but not necessarily the same subpiece of that object. |
protected void |
set(String protocol,
String host,
int port,
String file,
String ref)
Sets the fields of the URL. |
static void |
setURLStreamHandlerFactory(URLStreamHandlerFactory fac)
Sets the URLStreamHandler factory. |
String |
toExternalForm()
Reverses the parsing of the URL. |
String |
toString()
Converts to a human-readable form. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public URL(String protocol,
String host,
int port,
String file)
throws MalformedURLException
protocol - the protocol to usehost - the host to connect toport - the port at that host to connect tofile - the file on that host
MalformedURLException - If an unknown protocol is
found.
public URL(String protocol,
String host,
String file)
throws MalformedURLException
protocol - the protocol to usehost - the host to connect tofile - the file on that host
MalformedURLException - If an unknown protocol is
found.
public URL(String spec)
throws MalformedURLException
spec - the URL String to parse
public URL(URL context,
String spec)
throws MalformedURLException
context - the context to parse the URL tospec - the URL String to parse
MalformedURLException - If the protocol is equal to null.| Method Detail |
protected void set(String protocol,
String host,
int port,
String file,
String ref)
protocol - the protocol to usehost - the host name to connecto toport - the protocol port to connect tofile - the specified file name on that hostref - the referencepublic int getPort()
public String getProtocol()
public String getHost()
public String getFile()
public String getRef()
public boolean equals(Object obj)
equals in class Objectobj - the URL to compare against.
Hashtablepublic int hashCode()
hashCode in class ObjectHashtablepublic boolean sameFile(URL other)
other - the URL to compare against.
public String toString()
toString in class Objectpublic String toExternalForm()
public URLConnection openConnection()
throws IOException
IOException - If an I/O exception has occurred.URLConnection
public final InputStream openStream()
throws IOException
IOException - If an I/O exception has occurred.
public final Object getContent()
throws IOException
IOException - If an I/O exception has occurred.public static void setURLStreamHandlerFactory(URLStreamHandlerFactory fac)
fac - the desired factory
Error - If the factory has already been defined.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||