package ch13;
import java.net.URL;
public class URLDemo {
public static void main(String[] args) throws Exception {
URL Aurl = new URL("http://java.sun.com/docs/books/");
URL tuto = new URL(Aurl, "tutorial.intro.html#DOWNLOADING");
System.out.println("protocol=" + tuto.getProtocol());
System.out.println("host =" + tuto.getHost());
System.out.println("filename=" + tuto.getFile());
System.out.println("port=" + tuto.getPort());
System.out.println("ref=" + tuto.getRef());
System.out.println("query=" + tuto.getQuery());
System.out.println("path=" + tuto.getPath());
}
}
java根据指定的路径构造URL对象,获取当前URL对象的相关属性信息,并将结果打印到控制台
最新推荐文章于 2024-07-10 14:15:00 发布