java.net the URL class in the package

Source: Internet
Author: User

A URI (Unform resources Identifier) is a Uniform resource identifier that uniquely identifies a resource, which is a URI for a resource. Consists of four parts, the protocol, the host domain name of the resource, the resource file name, the port number.

The URL (unform Resource Locator) is a Uniform Resource locator and is a specific URI. You can think of a URL as a "pointer" to an Internet resource.

The resource file name contains the file path, usually a relative path, relative to the app you are accessing. The java.net package has a URL class that provides a number of constructor methods, a URL ("Http://www.baidu.com:80/index.html#a?uname=xiaoming") with a parameter, an absolute path creation, where # is an anchor, Represents a jump within an HTML page,? After is the user information, throws the exception is malformedurlexception, the parameter writes the not and the specification will throw this exception, the malformed URL.

There are also two parameters of the constructor, URL (url,string), take parameter 1 of the protocol, domain name, port number, reject path, plus parameter 2 relative path, left slash/behind is relative path. The URL ("http://www.baidu.com:80/index.html#a?uname=xiaoming", b.html) gets the http://www.baidu.com:80/b.html.
View protocol: Getprotocol () View relative path resource GetPath (), relative to host name, with more
View Host Name: GetHost () get Anchor Point Getref ()
View Port: Getport () Gets the user input parameter getquery () if there is an anchor point, the parameter is treated as part of the anchor, and the return is null
View resources: GetFile ()
This object can also get HTML page specific information OpenStream (), this method is the focus. HTML page consists of four parts, HTML tags for formatting data, CSS skin for landscaping data, JS for interactive data, data.
The OpenStream method returns a inputstream that links the byte input stream for the specified resource. The output stream input stream is not always clear, remember that in is the Readin read, read is the link to the resources read to a place, out is written write, link to the resources do not have to write things, is from somewhere to write things to the linked resources, write

java.net the URL class in the package

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.