forked from bjmashibing/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathURI.html
More file actions
2090 lines (1881 loc) · 96.6 KB
/
URI.html
File metadata and controls
2090 lines (1881 loc) · 96.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc -->
<title>URI (Java SE 12 & JDK 12 )</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="keywords" content="java.net.URI class">
<meta name="keywords" content="create()">
<meta name="keywords" content="parseServerAuthority()">
<meta name="keywords" content="normalize()">
<meta name="keywords" content="resolve()">
<meta name="keywords" content="relativize()">
<meta name="keywords" content="toURL()">
<meta name="keywords" content="getScheme()">
<meta name="keywords" content="isAbsolute()">
<meta name="keywords" content="isOpaque()">
<meta name="keywords" content="getRawSchemeSpecificPart()">
<meta name="keywords" content="getSchemeSpecificPart()">
<meta name="keywords" content="getRawAuthority()">
<meta name="keywords" content="getAuthority()">
<meta name="keywords" content="getRawUserInfo()">
<meta name="keywords" content="getUserInfo()">
<meta name="keywords" content="getHost()">
<meta name="keywords" content="getPort()">
<meta name="keywords" content="getRawPath()">
<meta name="keywords" content="getPath()">
<meta name="keywords" content="getRawQuery()">
<meta name="keywords" content="getQuery()">
<meta name="keywords" content="getRawFragment()">
<meta name="keywords" content="getFragment()">
<meta name="keywords" content="equals()">
<meta name="keywords" content="hashCode()">
<meta name="keywords" content="compareTo()">
<meta name="keywords" content="toString()">
<meta name="keywords" content="toASCIIString()">
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../jquery/jquery-ui.css" title="Style">
<script type="text/javascript" src="../../../script.js"></script>
<script type="text/javascript" src="../../../jquery/jszip/dist/jszip.min.js"></script>
<script type="text/javascript" src="../../../jquery/jszip-utils/dist/jszip-utils.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="../../../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script>
<![endif]-->
<script type="text/javascript" src="../../../jquery/jquery-3.3.1.js"></script>
<script type="text/javascript" src="../../../jquery/jquery-migrate-3.0.1.js"></script>
<script type="text/javascript" src="../../../jquery/jquery-ui.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="URI (Java SE 12 & JDK 12 )";
}
}
catch(err) {
}
//-->
var data = {"i0":10,"i1":9,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10,"i14":10,"i15":10,"i16":10,"i17":10,"i18":10,"i19":10,"i20":10,"i21":10,"i22":10,"i23":10,"i24":10,"i25":10,"i26":10,"i27":10,"i28":10};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
var pathtoroot = "../../../";
var useModuleDirectories = true;
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<header role="banner">
<nav role="navigation">
<div class="fixedNav">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a id="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../index.html">Overview</a></li>
<li><a href="../../module-summary.html">Module</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/URI.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><div style="margin-top: 14px;"><strong>Java SE 12 & JDK 12</strong> </div></div>
</div>
<div class="subNav">
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li>Field | </li>
<li><a href="#constructor.summary">Constr</a> | </li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li><a href="#constructor.detail">Constr</a> | </li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<ul class="navListSearch">
<li><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</li>
</ul>
</div>
<a id="skip.navbar.top">
<!-- -->
</a>
<!-- ========= END OF TOP NAVBAR ========= -->
</div>
<div class="navPadding"> </div>
<script type="text/javascript"><!--
$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
//-->
</script>
</nav>
</header>
<!-- ======== START OF CLASS DATA ======== -->
<main role="main">
<div class="header">
<div class="subTitle"><span class="moduleLabelInType">Module</span> <a href="../../module-summary.html">java.base</a></div>
<div class="subTitle"><span class="packageLabelInType">Package</span> <a href="package-summary.html">java.net</a></div>
<h2 title="Class URI" class="title">Class URI</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="../lang/Object.html" title="class in java.lang">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li>java.net.URI</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Implemented Interfaces:</dt>
<dd><code><a href="../io/Serializable.html" title="interface in java.io">Serializable</a></code>, <code><a href="../lang/Comparable.html" title="interface in java.lang">Comparable</a><<a href="URI.html" title="class in java.net">URI</a>></code></dd>
</dl>
<hr>
<pre>public final class <span class="typeNameLabel">URI</span>
extends <a href="../lang/Object.html" title="class in java.lang">Object</a>
implements <a href="../lang/Comparable.html" title="interface in java.lang">Comparable</a><<a href="URI.html" title="class in java.net">URI</a>>, <a href="../io/Serializable.html" title="interface in java.io">Serializable</a></pre>
<div class="block">Represents a Uniform Resource Identifier (URI) reference.
<p> Aside from some minor deviations noted below, an instance of this
class represents a URI reference as defined by
<a href="http://www.ietf.org/rfc/rfc2396.txt"><i>RFC 2396: Uniform
Resource Identifiers (URI): Generic Syntax</i></a>, amended by <a href="http://www.ietf.org/rfc/rfc2732.txt"><i>RFC 2732: Format for
Literal IPv6 Addresses in URLs</i></a>. The Literal IPv6 address format
also supports scope_ids. The syntax and usage of scope_ids is described
<a href="Inet6Address.html#scoped">here</a>.
This class provides constructors for creating URI instances from
their components or by parsing their string forms, methods for accessing the
various components of an instance, and methods for normalizing, resolving,
and relativizing URI instances. Instances of this class are immutable.
<h3> URI syntax and components </h3>
At the highest level a URI reference (hereinafter simply "URI") in string
form has the syntax
<blockquote>
[<i>scheme</i><b><code>:</code></b>]<i>scheme-specific-part</i>[<b><code>#</code></b><i>fragment</i>]
</blockquote>
where square brackets [...] delineate optional components and the characters
<b><code>:</code></b> and <b><code>#</code></b> stand for themselves.
<p> An <i>absolute</i> URI specifies a scheme; a URI that is not absolute is
said to be <i>relative</i>. URIs are also classified according to whether
they are <i>opaque</i> or <i>hierarchical</i>.
<p> An <i>opaque</i> URI is an absolute URI whose scheme-specific part does
not begin with a slash character (<code>'/'</code>). Opaque URIs are not
subject to further parsing. Some examples of opaque URIs are:
<blockquote><ul style="list-style-type:none">
<li><code>mailto:java-net@www.example.com</code></li>
<li><code>news:comp.lang.java</code></li>
<li><code>urn:isbn:096139210x</code></li>
</ul></blockquote>
<p> A <i>hierarchical</i> URI is either an absolute URI whose
scheme-specific part begins with a slash character, or a relative URI, that
is, a URI that does not specify a scheme. Some examples of hierarchical
URIs are:
<blockquote>
<code>http://example.com/languages/java/</code><br>
<code>sample/a/index.html#28</code><br>
<code>../../demo/b/index.html</code><br>
<code>file:///~/calendar</code>
</blockquote>
<p> A hierarchical URI is subject to further parsing according to the syntax
<blockquote>
[<i>scheme</i><b><code>:</code></b>][<b><code>//</code></b><i>authority</i>][<i>path</i>][<b><code>?</code></b><i>query</i>][<b><code>#</code></b><i>fragment</i>]
</blockquote>
where the characters <b><code>:</code></b>, <b><code>/</code></b>,
<b><code>?</code></b>, and <b><code>#</code></b> stand for themselves. The
scheme-specific part of a hierarchical URI consists of the characters
between the scheme and fragment components.
<p> The authority component of a hierarchical URI is, if specified, either
<i>server-based</i> or <i>registry-based</i>. A server-based authority
parses according to the familiar syntax
<blockquote>
[<i>user-info</i><b><code>@</code></b>]<i>host</i>[<b><code>:</code></b><i>port</i>]
</blockquote>
where the characters <b><code>@</code></b> and <b><code>:</code></b> stand for
themselves. Nearly all URI schemes currently in use are server-based. An
authority component that does not parse in this way is considered to be
registry-based.
<p> The path component of a hierarchical URI is itself said to be absolute
if it begins with a slash character (<code>'/'</code>); otherwise it is
relative. The path of a hierarchical URI that is either absolute or
specifies an authority is always absolute.
<p> All told, then, a URI instance has the following nine components:
<table class="striped" style="margin-left:2em">
<caption style="display:none">Describes the components of a URI:scheme,scheme-specific-part,authority,user-info,host,port,path,query,fragment</caption>
<thead>
<tr><th scope="col">Component</th><th scope="col">Type</th></tr>
</thead>
<tbody style="text-align:left">
<tr><th scope="row">scheme</th><td><code>String</code></td></tr>
<tr><th scope="row">scheme-specific-part</th><td><code>String</code></td></tr>
<tr><th scope="row">authority</th><td><code>String</code></td></tr>
<tr><th scope="row">user-info</th><td><code>String</code></td></tr>
<tr><th scope="row">host</th><td><code>String</code></td></tr>
<tr><th scope="row">port</th><td><code>int</code></td></tr>
<tr><th scope="row">path</th><td><code>String</code></td></tr>
<tr><th scope="row">query</th><td><code>String</code></td></tr>
<tr><th scope="row">fragment</th><td><code>String</code></td></tr>
</tbody>
</table>
In a given instance any particular component is either <i>undefined</i> or
<i>defined</i> with a distinct value. Undefined string components are
represented by <code>null</code>, while undefined integer components are
represented by <code>-1</code>. A string component may be defined to have the
empty string as its value; this is not equivalent to that component being
undefined.
<p> Whether a particular component is or is not defined in an instance
depends upon the type of the URI being represented. An absolute URI has a
scheme component. An opaque URI has a scheme, a scheme-specific part, and
possibly a fragment, but has no other components. A hierarchical URI always
has a path (though it may be empty) and a scheme-specific-part (which at
least contains the path), and may have any of the other components. If the
authority component is present and is server-based then the host component
will be defined and the user-information and port components may be defined.
<h4> Operations on URI instances </h4>
The key operations supported by this class are those of
<i>normalization</i>, <i>resolution</i>, and <i>relativization</i>.
<p> <i>Normalization</i> is the process of removing unnecessary <code>"."</code>
and <code>".."</code> segments from the path component of a hierarchical URI.
Each <code>"."</code> segment is simply removed. A <code>".."</code> segment is
removed only if it is preceded by a non-<code>".."</code> segment.
Normalization has no effect upon opaque URIs.
<p> <i>Resolution</i> is the process of resolving one URI against another,
<i>base</i> URI. The resulting URI is constructed from components of both
URIs in the manner specified by RFC 2396, taking components from the
base URI for those not specified in the original. For hierarchical URIs,
the path of the original is resolved against the path of the base and then
normalized. The result, for example, of resolving
<blockquote>
<code>sample/a/index.html#28</code>
(1)
</blockquote>
against the base URI <code>http://example.com/languages/java/</code> is the result
URI
<blockquote>
<code>http://example.com/languages/java/sample/a/index.html#28</code>
</blockquote>
Resolving the relative URI
<blockquote>
<code>../../demo/b/index.html</code> (2)
</blockquote>
against this result yields, in turn,
<blockquote>
<code>http://example.com/languages/java/demo/b/index.html</code>
</blockquote>
Resolution of both absolute and relative URIs, and of both absolute and
relative paths in the case of hierarchical URIs, is supported. Resolving
the URI <code>file:///~calendar</code> against any other URI simply yields the
original URI, since it is absolute. Resolving the relative URI (2) above
against the relative base URI (1) yields the normalized, but still relative,
URI
<blockquote>
<code>demo/b/index.html</code>
</blockquote>
<p> <i>Relativization</i>, finally, is the inverse of resolution: For any
two normalized URIs <i>u</i> and <i>v</i>,
<blockquote>
<i>u</i><code>.relativize(</code><i>u</i><code>.resolve(</code><i>v</i><code>)).equals(</code><i>v</i><code>)</code> and<br>
<i>u</i><code>.resolve(</code><i>u</i><code>.relativize(</code><i>v</i><code>)).equals(</code><i>v</i><code>)</code> .<br>
</blockquote>
This operation is often useful when constructing a document containing URIs
that must be made relative to the base URI of the document wherever
possible. For example, relativizing the URI
<blockquote>
<code>http://example.com/languages/java/sample/a/index.html#28</code>
</blockquote>
against the base URI
<blockquote>
<code>http://example.com/languages/java/</code>
</blockquote>
yields the relative URI <code>sample/a/index.html#28</code>.
<h4> Character categories </h4>
RFC 2396 specifies precisely which characters are permitted in the
various components of a URI reference. The following categories, most of
which are taken from that specification, are used below to describe these
constraints:
<table class="striped" style="margin-left:2em">
<caption style="display:none">Describes categories alpha,digit,alphanum,unreserved,punct,reserved,escaped,and other</caption>
<thead>
<tr><th scope="col">Category</th><th scope="col">Description</th></tr>
</thead>
<tbody style="text-align:left">
<tr><th scope="row" style="vertical-align:top">alpha</th>
<td>The US-ASCII alphabetic characters,
<code>'A'</code> through <code>'Z'</code>
and <code>'a'</code> through <code>'z'</code></td></tr>
<tr><th scope="row" style="vertical-align:top">digit</th>
<td>The US-ASCII decimal digit characters,
<code>'0'</code> through <code>'9'</code></td></tr>
<tr><th scope="row" style="vertical-align:top">alphanum</th>
<td>All <i>alpha</i> and <i>digit</i> characters</td></tr>
<tr><th scope="row" style="vertical-align:top">unreserved</th>
<td>All <i>alphanum</i> characters together with those in the string
<code>"_-!.~'()*"</code></td></tr>
<tr><th scope="row" style="vertical-align:top">punct</th>
<td>The characters in the string <code>",;:$&+="</code></td></tr>
<tr><th scope="row" style="vertical-align:top">reserved</th>
<td>All <i>punct</i> characters together with those in the string
<code>"?/[]@"</code></td></tr>
<tr><th scope="row" style="vertical-align:top">escaped</th>
<td>Escaped octets, that is, triplets consisting of the percent
character (<code>'%'</code>) followed by two hexadecimal digits
(<code>'0'</code>-<code>'9'</code>, <code>'A'</code>-<code>'F'</code>, and
<code>'a'</code>-<code>'f'</code>)</td></tr>
<tr><th scope="row" style="vertical-align:top">other</th>
<td>The Unicode characters that are not in the US-ASCII character set,
are not control characters (according to the <a href="../lang/Character.html#isISOControl(char)"><code>Character.isISOControl</code></a>
method), and are not space characters (according to the <a href="../lang/Character.html#isSpaceChar(char)"><code>Character.isSpaceChar</code></a>
method) <i>(<b>Deviation from RFC 2396</b>, which is
limited to US-ASCII)</i></td></tr>
</tbody>
</table>
<p><a id="legal-chars"></a> The set of all legal URI characters consists of
the <i>unreserved</i>, <i>reserved</i>, <i>escaped</i>, and <i>other</i>
characters.
<h4> Escaped octets, quotation, encoding, and decoding </h4>
RFC 2396 allows escaped octets to appear in the user-info, path, query, and
fragment components. Escaping serves two purposes in URIs:
<ul>
<li><p> To <i>encode</i> non-US-ASCII characters when a URI is required to
conform strictly to RFC 2396 by not containing any <i>other</i>
characters. </p></li>
<li><p> To <i>quote</i> characters that are otherwise illegal in a
component. The user-info, path, query, and fragment components differ
slightly in terms of which characters are considered legal and illegal.
</p></li>
</ul>
These purposes are served in this class by three related operations:
<ul>
<li><p><a id="encode"></a> A character is <i>encoded</i> by replacing it
with the sequence of escaped octets that represent that character in the
UTF-8 character set. The Euro currency symbol (<code>'\u20AC'</code>),
for example, is encoded as <code>"%E2%82%AC"</code>. <i>(<b>Deviation from
RFC 2396</b>, which does not specify any particular character
set.)</i> </p></li>
<li><p><a id="quote"></a> An illegal character is <i>quoted</i> simply by
encoding it. The space character, for example, is quoted by replacing it
with <code>"%20"</code>. UTF-8 contains US-ASCII, hence for US-ASCII
characters this transformation has exactly the effect required by
RFC 2396. </p></li>
<li><p><a id="decode"></a>
A sequence of escaped octets is <i>decoded</i> by
replacing it with the sequence of characters that it represents in the
UTF-8 character set. UTF-8 contains US-ASCII, hence decoding has the
effect of de-quoting any quoted US-ASCII characters as well as that of
decoding any encoded non-US-ASCII characters. If a <a href="../nio/charset/CharsetDecoder.html#ce">decoding error</a> occurs
when decoding the escaped octets then the erroneous octets are replaced by
<code>'\uFFFD'</code>, the Unicode replacement character. </p></li>
</ul>
These operations are exposed in the constructors and methods of this class
as follows:
<ul>
<li><p> The <a href="#%3Cinit%3E(java.lang.String)">single-argument
constructor</a> requires any illegal characters in its argument to be
quoted and preserves any escaped octets and <i>other</i> characters that
are present. </p></li>
<li><p> The <a href="#%3Cinit%3E(java.lang.String,java.lang.String,java.lang.String,int,java.lang.String,java.lang.String,java.lang.String)">multi-argument constructors</a> quote illegal characters as
required by the components in which they appear. The percent character
(<code>'%'</code>) is always quoted by these constructors. Any <i>other</i>
characters are preserved. </p></li>
<li><p> The <a href="#getRawUserInfo()"><code>getRawUserInfo</code></a>, <a href="#getRawPath()"><code>getRawPath</code></a>, <a href="#getRawQuery()"><code>getRawQuery</code></a>, <a href="#getRawFragment()"><code>getRawFragment</code></a>, <a href="#getRawAuthority()"><code>getRawAuthority</code></a>, and <a href="#getRawSchemeSpecificPart()"><code>getRawSchemeSpecificPart</code></a> methods return the
values of their corresponding components in raw form, without interpreting
any escaped octets. The strings returned by these methods may contain
both escaped octets and <i>other</i> characters, and will not contain any
illegal characters. </p></li>
<li><p> The <a href="#getUserInfo()"><code>getUserInfo</code></a>, <a href="#getPath()"><code>getPath</code></a>, <a href="#getQuery()"><code>getQuery</code></a>, <a href="#getFragment()"><code>getFragment</code></a>, <a href="#getAuthority()"><code>getAuthority</code></a>, and <a href="#getSchemeSpecificPart()"><code>getSchemeSpecificPart</code></a> methods decode any escaped
octets in their corresponding components. The strings returned by these
methods may contain both <i>other</i> characters and illegal characters,
and will not contain any escaped octets. </p></li>
<li><p> The <a href="#toString()"><code>toString</code></a> method returns a URI string with
all necessary quotation but which may contain <i>other</i> characters.
</p></li>
<li><p> The <a href="#toASCIIString()"><code>toASCIIString</code></a> method returns a fully
quoted and encoded URI string that does not contain any <i>other</i>
characters. </p></li>
</ul>
<h4> Identities </h4>
For any URI <i>u</i>, it is always the case that
<blockquote>
<code>new URI(</code><i>u</i><code>.toString()).equals(</code><i>u</i><code>)</code> .
</blockquote>
For any URI <i>u</i> that does not contain redundant syntax such as two
slashes before an empty authority (as in <code>file:///tmp/</code> ) or a
colon following a host name but no port (as in
<code>http://www.example.com:</code> ), and that does not encode characters
except those that must be quoted, the following identities also hold:
<pre>
new URI(<i>u</i>.getScheme(),
<i>u</i>.getSchemeSpecificPart(),
<i>u</i>.getFragment())
.equals(<i>u</i>)</pre>
in all cases,
<pre>
new URI(<i>u</i>.getScheme(),
<i>u</i>.getAuthority(),
<i>u</i>.getPath(), <i>u</i>.getQuery(),
<i>u</i>.getFragment())
.equals(<i>u</i>)</pre>
if <i>u</i> is hierarchical, and
<pre>
new URI(<i>u</i>.getScheme(),
<i>u</i>.getUserInfo(), <i>u</i>.getHost(), <i>u</i>.getPort(),
<i>u</i>.getPath(), <i>u</i>.getQuery(),
<i>u</i>.getFragment())
.equals(<i>u</i>)</pre>
if <i>u</i> is hierarchical and has either no authority or a server-based
authority.
<h4> URIs, URLs, and URNs </h4>
A URI is a uniform resource <i>identifier</i> while a URL is a uniform
resource <i>locator</i>. Hence every URL is a URI, abstractly speaking, but
not every URI is a URL. This is because there is another subcategory of
URIs, uniform resource <i>names</i> (URNs), which name resources but do not
specify how to locate them. The <code>mailto</code>, <code>news</code>, and
<code>isbn</code> URIs shown above are examples of URNs.
<p> The conceptual distinction between URIs and URLs is reflected in the
differences between this class and the <a href="URL.html" title="class in java.net"><code>URL</code></a> class.
<p> An instance of this class represents a URI reference in the syntactic
sense defined by RFC 2396. A URI may be either absolute or relative.
A URI string is parsed according to the generic syntax without regard to the
scheme, if any, that it specifies. No lookup of the host, if any, is
performed, and no scheme-dependent stream handler is constructed. Equality,
hashing, and comparison are defined strictly in terms of the character
content of the instance. In other words, a URI instance is little more than
a structured string that supports the syntactic, scheme-independent
operations of comparison, normalization, resolution, and relativization.
<p> An instance of the <a href="URL.html" title="class in java.net"><code>URL</code></a> class, by contrast, represents the
syntactic components of a URL together with some of the information required
to access the resource that it describes. A URL must be absolute, that is,
it must always specify a scheme. A URL string is parsed according to its
scheme. A stream handler is always established for a URL, and in fact it is
impossible to create a URL instance for a scheme for which no handler is
available. Equality and hashing depend upon both the scheme and the
Internet address of the host, if any; comparison is not defined. In other
words, a URL is a structured string that supports the syntactic operation of
resolution as well as the network I/O operations of looking up the host and
opening a connection to the specified resource.</div>
<dl>
<dt><span class="simpleTagLabel">API Note:</span></dt>
<dd>Applications working with file paths and file URIs should take great
care to use the appropriate methods to convert between the two.
The <a href="../nio/file/Path.html#of(java.net.URI)"><code>Path.of(URI)</code></a> factory method and the <a href="../io/File.html#%3Cinit%3E(java.net.URI)"><code>File(URI)</code></a>
constructor can be used to create <a href="../nio/file/Path.html" title="interface in java.nio.file"><code>Path</code></a> or <a href="../io/File.html" title="class in java.io"><code>File</code></a>
objects from a file URI. <a href="../nio/file/Path.html#toUri()"><code>Path.toUri()</code></a> and <a href="../io/File.html#toURI()"><code>File.toURI()</code></a>
can be used to create a <a href="URI.html" title="class in java.net"><code>URI</code></a> from a file path.
Applications should never try to <a href="#%3Cinit%3E(java.lang.String,java.lang.String,java.lang.String,int,java.lang.String,java.lang.String,java.lang.String)">construct</a>, <a href="#%3Cinit%3E(java.lang.String)">parse</a>, or
<a href="#resolve(java.lang.String)">resolve</a> a <code>URI</code>
from the direct string representation of a <code>File</code> or <code>Path</code>
instance.
<p>
Some components of a URL or URI, such as <i>userinfo</i>, may
be abused to construct misleading URLs or URIs. Applications
that deal with URLs or URIs should take into account
the recommendations advised in <a href="https://tools.ietf.org/html/rfc3986#section-7">RFC3986,
Section 7, Security Considerations</a>.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.4</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="http://www.ietf.org/rfc/rfc2279.txt"><i>RFC 2279: UTF-8, a
transformation format of ISO 10646</i></a>, <br><a href="http://www.ietf.org/rfc/rfc2373.txt"><i>RFC 2373: IPv6 Addressing
Architecture</i></a>, <br><a href="http://www.ietf.org/rfc/rfc2396.txt"><i>RFC 2396: Uniform
Resource Identifiers (URI): Generic Syntax</i></a>, <br><a href="http://www.ietf.org/rfc/rfc2732.txt"><i>RFC 2732: Format for
Literal IPv6 Addresses in URLs</i></a>, <br><a href="URISyntaxException.html">URISyntaxException</a>,
<a href="../../../serialized-form.html#java.net.URI">Serialized Form</a></dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="constructor.summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<div class="memberSummary">
<table>
<caption><span>Constructors</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Constructor</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E(java.lang.String)">URI</a></span>​(<a href="../lang/String.html" title="class in java.lang">String</a> str)</code></th>
<td class="colLast">
<div class="block">Constructs a URI by parsing the given string.</div>
</td>
</tr>
<tr class="rowColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E(java.lang.String,java.lang.String,java.lang.String)">URI</a></span>​(<a href="../lang/String.html" title="class in java.lang">String</a> scheme,
<a href="../lang/String.html" title="class in java.lang">String</a> ssp,
<a href="../lang/String.html" title="class in java.lang">String</a> fragment)</code></th>
<td class="colLast">
<div class="block">Constructs a URI from the given components.</div>
</td>
</tr>
<tr class="altColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E(java.lang.String,java.lang.String,java.lang.String,int,java.lang.String,java.lang.String,java.lang.String)">URI</a></span>​(<a href="../lang/String.html" title="class in java.lang">String</a> scheme,
<a href="../lang/String.html" title="class in java.lang">String</a> userInfo,
<a href="../lang/String.html" title="class in java.lang">String</a> host,
int port,
<a href="../lang/String.html" title="class in java.lang">String</a> path,
<a href="../lang/String.html" title="class in java.lang">String</a> query,
<a href="../lang/String.html" title="class in java.lang">String</a> fragment)</code></th>
<td class="colLast">
<div class="block">Constructs a hierarchical URI from the given components.</div>
</td>
</tr>
<tr class="rowColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E(java.lang.String,java.lang.String,java.lang.String,java.lang.String)">URI</a></span>​(<a href="../lang/String.html" title="class in java.lang">String</a> scheme,
<a href="../lang/String.html" title="class in java.lang">String</a> host,
<a href="../lang/String.html" title="class in java.lang">String</a> path,
<a href="../lang/String.html" title="class in java.lang">String</a> fragment)</code></th>
<td class="colLast">
<div class="block">Constructs a hierarchical URI from the given components.</div>
</td>
</tr>
<tr class="altColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)">URI</a></span>​(<a href="../lang/String.html" title="class in java.lang">String</a> scheme,
<a href="../lang/String.html" title="class in java.lang">String</a> authority,
<a href="../lang/String.html" title="class in java.lang">String</a> path,
<a href="../lang/String.html" title="class in java.lang">String</a> query,
<a href="../lang/String.html" title="class in java.lang">String</a> fragment)</code></th>
<td class="colLast">
<div class="block">Constructs a hierarchical URI from the given components.</div>
</td>
</tr>
</tbody>
</table>
</div>
</li>
</ul>
</section>
<!-- ========== METHOD SUMMARY =========== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<div class="memberSummary">
<div role="tablist" aria-orientation="horizontal"><button role="tab" aria-selected="true" aria-controls="memberSummary_tabpanel" tabindex="0" onkeydown="switchTab(event)" id="t0" class="activeTableTab">All Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t1" class="tableTab" onclick="show(1);">Static Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t2" class="tableTab" onclick="show(2);">Instance Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t4" class="tableTab" onclick="show(8);">Concrete Methods</button></div>
<div id="memberSummary_tabpanel" role="tabpanel">
<table aria-labelledby="t0">
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Method</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor" id="i0">
<td class="colFirst"><code>int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#compareTo(java.net.URI)">compareTo</a></span>​(<a href="URI.html" title="class in java.net">URI</a> that)</code></th>
<td class="colLast">
<div class="block">Compares this URI to another object, which must be a URI.</div>
</td>
</tr>
<tr class="rowColor" id="i1">
<td class="colFirst"><code>static <a href="URI.html" title="class in java.net">URI</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#create(java.lang.String)">create</a></span>​(<a href="../lang/String.html" title="class in java.lang">String</a> str)</code></th>
<td class="colLast">
<div class="block">Creates a URI by parsing the given string.</div>
</td>
</tr>
<tr class="altColor" id="i2">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#equals(java.lang.Object)">equals</a></span>​(<a href="../lang/Object.html" title="class in java.lang">Object</a> ob)</code></th>
<td class="colLast">
<div class="block">Tests this URI for equality with another object.</div>
</td>
</tr>
<tr class="rowColor" id="i3">
<td class="colFirst"><code><a href="../lang/String.html" title="class in java.lang">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getAuthority()">getAuthority</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the decoded authority component of this URI.</div>
</td>
</tr>
<tr class="altColor" id="i4">
<td class="colFirst"><code><a href="../lang/String.html" title="class in java.lang">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getFragment()">getFragment</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the decoded fragment component of this URI.</div>
</td>
</tr>
<tr class="rowColor" id="i5">
<td class="colFirst"><code><a href="../lang/String.html" title="class in java.lang">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getHost()">getHost</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the host component of this URI.</div>
</td>
</tr>
<tr class="altColor" id="i6">
<td class="colFirst"><code><a href="../lang/String.html" title="class in java.lang">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getPath()">getPath</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the decoded path component of this URI.</div>
</td>
</tr>
<tr class="rowColor" id="i7">
<td class="colFirst"><code>int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getPort()">getPort</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the port number of this URI.</div>
</td>
</tr>
<tr class="altColor" id="i8">
<td class="colFirst"><code><a href="../lang/String.html" title="class in java.lang">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getQuery()">getQuery</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the decoded query component of this URI.</div>
</td>
</tr>
<tr class="rowColor" id="i9">
<td class="colFirst"><code><a href="../lang/String.html" title="class in java.lang">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getRawAuthority()">getRawAuthority</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the raw authority component of this URI.</div>
</td>
</tr>
<tr class="altColor" id="i10">
<td class="colFirst"><code><a href="../lang/String.html" title="class in java.lang">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getRawFragment()">getRawFragment</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the raw fragment component of this URI.</div>
</td>
</tr>
<tr class="rowColor" id="i11">
<td class="colFirst"><code><a href="../lang/String.html" title="class in java.lang">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getRawPath()">getRawPath</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the raw path component of this URI.</div>
</td>
</tr>
<tr class="altColor" id="i12">
<td class="colFirst"><code><a href="../lang/String.html" title="class in java.lang">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getRawQuery()">getRawQuery</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the raw query component of this URI.</div>
</td>
</tr>
<tr class="rowColor" id="i13">
<td class="colFirst"><code><a href="../lang/String.html" title="class in java.lang">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getRawSchemeSpecificPart()">getRawSchemeSpecificPart</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the raw scheme-specific part of this URI.</div>
</td>
</tr>
<tr class="altColor" id="i14">
<td class="colFirst"><code><a href="../lang/String.html" title="class in java.lang">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getRawUserInfo()">getRawUserInfo</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the raw user-information component of this URI.</div>
</td>
</tr>
<tr class="rowColor" id="i15">
<td class="colFirst"><code><a href="../lang/String.html" title="class in java.lang">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getScheme()">getScheme</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the scheme component of this URI.</div>
</td>
</tr>
<tr class="altColor" id="i16">
<td class="colFirst"><code><a href="../lang/String.html" title="class in java.lang">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getSchemeSpecificPart()">getSchemeSpecificPart</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the decoded scheme-specific part of this URI.</div>
</td>
</tr>
<tr class="rowColor" id="i17">
<td class="colFirst"><code><a href="../lang/String.html" title="class in java.lang">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getUserInfo()">getUserInfo</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the decoded user-information component of this URI.</div>
</td>
</tr>
<tr class="altColor" id="i18">
<td class="colFirst"><code>int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#hashCode()">hashCode</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns a hash-code value for this URI.</div>
</td>
</tr>
<tr class="rowColor" id="i19">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#isAbsolute()">isAbsolute</a></span>()</code></th>
<td class="colLast">
<div class="block">Tells whether or not this URI is absolute.</div>
</td>
</tr>
<tr class="altColor" id="i20">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#isOpaque()">isOpaque</a></span>()</code></th>
<td class="colLast">
<div class="block">Tells whether or not this URI is opaque.</div>
</td>
</tr>
<tr class="rowColor" id="i21">
<td class="colFirst"><code><a href="URI.html" title="class in java.net">URI</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#normalize()">normalize</a></span>()</code></th>
<td class="colLast">
<div class="block">Normalizes this URI's path.</div>
</td>
</tr>
<tr class="altColor" id="i22">
<td class="colFirst"><code><a href="URI.html" title="class in java.net">URI</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#parseServerAuthority()">parseServerAuthority</a></span>()</code></th>
<td class="colLast">
<div class="block">Attempts to parse this URI's authority component, if defined, into
user-information, host, and port components.</div>
</td>
</tr>
<tr class="rowColor" id="i23">
<td class="colFirst"><code><a href="URI.html" title="class in java.net">URI</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#relativize(java.net.URI)">relativize</a></span>​(<a href="URI.html" title="class in java.net">URI</a> uri)</code></th>
<td class="colLast">
<div class="block">Relativizes the given URI against this URI.</div>
</td>
</tr>
<tr class="altColor" id="i24">
<td class="colFirst"><code><a href="URI.html" title="class in java.net">URI</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#resolve(java.lang.String)">resolve</a></span>​(<a href="../lang/String.html" title="class in java.lang">String</a> str)</code></th>
<td class="colLast">
<div class="block">Constructs a new URI by parsing the given string and then resolving it
against this URI.</div>
</td>
</tr>
<tr class="rowColor" id="i25">
<td class="colFirst"><code><a href="URI.html" title="class in java.net">URI</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#resolve(java.net.URI)">resolve</a></span>​(<a href="URI.html" title="class in java.net">URI</a> uri)</code></th>
<td class="colLast">
<div class="block">Resolves the given URI against this URI.</div>
</td>
</tr>
<tr class="altColor" id="i26">
<td class="colFirst"><code><a href="../lang/String.html" title="class in java.lang">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#toASCIIString()">toASCIIString</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the content of this URI as a US-ASCII string.</div>
</td>
</tr>
<tr class="rowColor" id="i27">
<td class="colFirst"><code><a href="../lang/String.html" title="class in java.lang">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#toString()">toString</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the content of this URI as a string.</div>
</td>
</tr>
<tr class="altColor" id="i28">
<td class="colFirst"><code><a href="URL.html" title="class in java.net">URL</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#toURL()">toURL</a></span>()</code></th>
<td class="colLast">
<div class="block">Constructs a URL from this URI.</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<ul class="blockList">
<li class="blockList"><a id="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods declared in class java.lang.<a href="../lang/Object.html" title="class in java.lang">Object</a></h3>
<code><a href="../lang/Object.html#clone()">clone</a>, <a href="../lang/Object.html#finalize()">finalize</a>, <a href="../lang/Object.html#getClass()">getClass</a>, <a href="../lang/Object.html#notify()">notify</a>, <a href="../lang/Object.html#notifyAll()">notifyAll</a>, <a href="../lang/Object.html#wait()">wait</a>, <a href="../lang/Object.html#wait(long)">wait</a>, <a href="../lang/Object.html#wait(long,int)">wait</a></code></li>
</ul>
</li>
</ul>
</section>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="constructor.detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a id="<init>(java.lang.String)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>URI</h4>
<pre>public URI​(<a href="../lang/String.html" title="class in java.lang">String</a> str)
throws <a href="URISyntaxException.html" title="class in java.net">URISyntaxException</a></pre>
<div class="block">Constructs a URI by parsing the given string.
<p> This constructor parses the given string exactly as specified by the
grammar in <a href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396</a>,
Appendix A, <b><i>except for the following deviations:</i></b> </p>
<ul>
<li><p> An empty authority component is permitted as long as it is
followed by a non-empty path, a query component, or a fragment
component. This allows the parsing of URIs such as
<code>"file:///foo/bar"</code>, which seems to be the intent of
RFC 2396 although the grammar does not permit it. If the
authority component is empty then the user-information, host, and port
components are undefined. </p></li>
<li><p> Empty relative paths are permitted; this seems to be the
intent of RFC 2396 although the grammar does not permit it. The
primary consequence of this deviation is that a standalone fragment
such as <code>"#foo"</code> parses as a relative URI with an empty path
and the given fragment, and can be usefully <a href="#resolve-frag">resolved</a> against a base URI.
<li><p> IPv4 addresses in host components are parsed rigorously, as
specified by <a href="http://www.ietf.org/rfc/rfc2732.txt">RFC 2732</a>: Each
element of a dotted-quad address must contain no more than three
decimal digits. Each element is further constrained to have a value
no greater than 255. </p></li>
<li> <p> Hostnames in host components that comprise only a single
domain label are permitted to start with an <i>alphanum</i>
character. This seems to be the intent of <a href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396</a>
section 3.2.2 although the grammar does not permit it. The
consequence of this deviation is that the authority component of a
hierarchical URI such as <code>s://123</code>, will parse as a server-based
authority. </p></li>
<li><p> IPv6 addresses are permitted for the host component. An IPv6
address must be enclosed in square brackets (<code>'['</code> and
<code>']'</code>) as specified by <a href="http://www.ietf.org/rfc/rfc2732.txt">RFC 2732</a>. The
IPv6 address itself must parse according to <a href="http://www.ietf.org/rfc/rfc2373.txt">RFC 2373</a>. IPv6
addresses are further constrained to describe no more than sixteen
bytes of address information, a constraint implicit in RFC 2373
but not expressible in the grammar. </p></li>
<li><p> Characters in the <i>other</i> category are permitted wherever
RFC 2396 permits <i>escaped</i> octets, that is, in the
user-information, path, query, and fragment components, as well as in
the authority component if the authority is registry-based. This
allows URIs to contain Unicode characters beyond those in the US-ASCII
character set. </p></li>
</ul></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>str</code> - The string to be parsed into a URI</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="../lang/NullPointerException.html" title="class in java.lang">NullPointerException</a></code> - If <code>str</code> is <code>null</code></dd>
<dd><code><a href="URISyntaxException.html" title="class in java.net">URISyntaxException</a></code> - If the given string violates RFC 2396, as augmented
by the above deviations</dd>
</dl>
</li>
</ul>
<a id="<init>(java.lang.String,java.lang.String,java.lang.String,int,java.lang.String,java.lang.String,java.lang.String)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>URI</h4>
<pre>public URI​(<a href="../lang/String.html" title="class in java.lang">String</a> scheme,
<a href="../lang/String.html" title="class in java.lang">String</a> userInfo,
<a href="../lang/String.html" title="class in java.lang">String</a> host,
int port,
<a href="../lang/String.html" title="class in java.lang">String</a> path,
<a href="../lang/String.html" title="class in java.lang">String</a> query,
<a href="../lang/String.html" title="class in java.lang">String</a> fragment)
throws <a href="URISyntaxException.html" title="class in java.net">URISyntaxException</a></pre>
<div class="block">Constructs a hierarchical URI from the given components.
<p> If a scheme is given then the path, if also given, must either be
empty or begin with a slash character (<code>'/'</code>). Otherwise a
component of the new URI may be left undefined by passing <code>null</code>
for the corresponding parameter or, in the case of the <code>port</code>
parameter, by passing <code>-1</code>.
<p> This constructor first builds a URI string from the given components
according to the rules specified in <a href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396</a>,
section 5.2, step 7: </p>