-
public URL(String spec);
- 通过一个表示URL地址的字符串可以直接构造一个URL对象
- eg: URL url = new URL("http;//www.atguigu.com/’);
-
public URL(URL context , String spec);
- 通过基URL和相对URL构造一个URL对象
- eg: new URL(url , “download.html”);
-
public URL(String protocol , String host , String file);
- 通过: 协议名,主机名/域名,文件名来构造一个URL对象
- eg: new URL(“http” , “www.atguigu.com” , “download.html”);
-
public URL(String protocol , String host , int port , String file);
- 通过 : 协议名,主机名/域名,端口号,文件名来构造一个URL对象
- eg: new URL(“http” , “www.atguigu.com”,8080,“download.html”);