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?