URL:统一资源定位器
协议
域名、计算机名
端口:默认80
资源(#为锚点)
http://www.baidu.com:80/index.html?uname=shsxt&age=18#a

public class http {

public static void main(String[]args) throws  MalformedURLException
{
    URL url =new URL("http://www.baidu.com:80/index.html?uname=shsxt&age=18#a");
    //获取四个值
    System.out.println("协议:"+url.getProtocol());
    System.out.println("域名/ip:"+url.getHost());
    System.out.println("端口:"+url.getPort());
    System.out.println("请求资源:"+url.getFile());
    System.out.println("请求资源:"+url.getPath());

    //参数
    System.out.println("参数:"+url.getQuery());

    //锚点
    System.out.println("锚点:"+url.getRef());

}
}