package com.aflfte.loc;
import java.net.URL;
/**
* URL:统一资源定位器,互联网三大基石之一(html,http)
* 1.协议
* 2.域名或计算机名
* 3.端口
* 4.请求资源
*
* @author root
*
*/
public class URLTest01 {
public static void main(String[] args) throws Exception {
URL url=new URL("https://www.baidu.com:80/baidu?wd=%E7%9F%B3%E7%AC%BC%E7%BD%91&tn=ubuntuu_cb&ie=utf-8#3");
//获取四个值
System.out.println("协议:"+url.getProtocol());
System.out.println("域名或IP:"+url.getHost());
System.out.println("请求资源:"+url.getFile());
System.out.println("请求资源:"+url.getPath());
System.out.println("端口"+url.getPort());
//参数和锚点
System.out.println("参数:"+url.getQuery());
System.out.println("锚点:"+url.getRef());
}
}
« UDP发送与接收数据
|
端口(InetSocketAddress的使用)»
|