Mport java.net .*;
IMPORT java. Io .*;
Public class parseurl {
Public static void main (string [] ARGs)
Throws exception {
URL aurl = new URL ("http://java.sun.com: 80/docs/books/tutorial" + "/index.html? Name = networking # downloading ");
System. Out. println ("protocol =" + aurl. getprotocol ());
System. Out. println ("authority =" + aurl. getauthority (); system. Out. println ("host =" + aurl. gethost ());
System. Out. println ("Port =" + aurl. getport ());
System. Out. println ("Path =" + aurl. getpath ());
System. Out. println ("query =" + aurl. getquery ());
System. Out. println ("filename =" + aurl. GetFile ());
System. Out. println ("ref =" + aurl. getref ());
}
}
ut: Ut: Protocol = http
ut: Ut: Authority = localhost: 8080
ut: Ut: host = localhost
ut: Ut: port = 8080
ut: Ut: Path =/ut2.0/login. action
ut: Ut: query = NULL
ut: Ut: filename =/ut2.0/login. action
ut: Ut: ref = NULL