/*
URL is http://www.java2s.com
authority is www.java2s.com
path is
default port is 80
query is null
ref is null
*/
import java.io.IOException;
import java.net.URL;
public class MainClass {
public static void main(String[] args) {
try {
URL url = new URL("http://www.java2s.com");
System.out.println("URL is " + url.toString());
System.out.println("authority is " + url.getAuthority());
System.out.println("path is " + url.getPath());
System.out.println("default port is " + url.getDefaultPort());
System.out.println("query is " + url.getQuery());
System.out.println("ref is " + url.getRef());
} catch (IOException e) {
e.printStackTrace();
}
}
}