Næste |
|
Java i netværk serie, Planche nr. 13 |
![]() |
Metoder på URL-objekt |
URL-objektet kan fortolke URL'en.
import java.net.*; import java.io.*; public class ParseURL { public static void main(String[] args) throws Exception { URL aURL = new URL("http://www.blanet.dk:80/kursus/java/links.html#udpak"); System.out.println("protocol = " + aURL.getProtocol()); System.out.println("host = " + aURL.getHost()); System.out.println("filename = " + aURL.getFile()); System.out.println("port = " + aURL.getPort()); System.out.println("ref = " + aURL.getRef()); } }