First, the URL hierarchy.
The creation of the URL object.
1, public URL (String spec);
URL urlbase=new url ("http://my.oschina.net/u/2308739/admin/new-blog.html");
2, public URL (url context,string spec);
URL urlbase=new url ("http://my.oschina.net/u/2308739/admin/");
URL indexurl=new url (urlbase, "new-blog.html");
3, Public URL (String protocol,string host,string file);
Constructs a URL object by protocol name, hostname, and file name.
New URL ("http", "Http://my.oschina.net", "/u/2308739/admin/new-blog.html");
4, P ublic URL (String protocol,string host,int port,string file);
Constructs a URL object through the protocol name, hostname, port number, and file name.
new URL ("http", "http://my.oschina.net","n", "/u/2308739/admin/new-blog.html");
Second, read the content through the URL
The OpenStream () method of the URL is used to get the object of the Java.io.inputstream class to read the contents of the URL address from the input stream.
The definition of this method is:
Public final InputStream OpenStream () throws IOException;
Java URL object initialization and reading content through URLs