![]() |
The Java Developers Almanac 1.4 |
|
e134. Parsing a URL try {
URL url = new URL("http://hostname:80/index.html#_top_");
String protocol = url.getProtocol(); // http
String host = url.getHost(); // hostname
int port = url.getPort(); // 80
String file = url.getFile(); // index.html
String ref = url.getRef(); // _top_
} catch (MalformedURLException e) {
}
e133. Converting Between a URL and a URI e135. Sending a POST Request Using a URL e136. Getting Text from a URL e137. Getting an Image from a URL e138. Getting a Jar File Using a URL e139. Accessing a Password-Protected URL
© 2002 Addison-Wesley. |