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”);
java.net.MalformedURLException继承于java.io.IOException
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)