What is the URI and URL of Java?

Source: Internet
Author: User

When we do development, often have the URI and URL confused problem, if at that time directly look at the URI and URL source code can not be confused. First I summarize the relationship between URI and URL: Their relationship is: The URL is a special URI, is the URI including the URL,

What exactly is a URI in the form of a formula?

uri=[scheme:]<scheme-specific-part>[#fragment] This can be obtained by Getscheme Getschemespecificpart and getfragment in the URI class.

When scheme is NULL, this URI is referred to as the relative URI. URI is called an absolute URI when scheme is not NULL

and <scheme-specfic-part>=[//authority]<path>[:query]

When path is empty, it is called an opaque URI, which is called a transparent URI when it is not empty.

Authority can also be divided into: [[email protected]]

From this formula we can see that the URI does include the URL.

Write a sample code below

Package Com.timo;import Java.net.URI; Public classUritest { Public Static voidMain (string[] args) throws exception{//create a URI, according to [scheme:]<scheme-specific-part>[#fragment]Uri uri =NewURI ("http","//[email protected]:8080/oi/oi?user= ' Aieg '","Iewio"); System. out. println (URI); System. out. println (Uri.getpath ()); }}

The picture of the debug code is as follows, from which you can see what each value of the above formula is.

What is the URI and URL of Java?

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.