forked from TimSongCoder/LearnJavaForAndroid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathURIComponents.java
More file actions
29 lines (26 loc) · 969 Bytes
/
Copy pathURIComponents.java
File metadata and controls
29 lines (26 loc) · 969 Bytes
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
import java.net.URI;
import java.net.URISyntaxException;
public class URIComponents{
public static void main(String[] args){
if(args.length != 1){
System.err.println("usage: java URIComponents uri");
return;
}
try{
URI uri = new URI(args[0]);
System.out.println("Authority = " + uri.getAuthority());
System.out.println("Fragment = " + uri.getFragment());
System.out.println("Host = " + uri.getHost());
System.out.println("Path = " + uri.getPath());
System.out.println("Port = " + uri.getPort());
System.out.println("Query = " + uri.getQuery());
System.out.println("Scheme = " + uri.getScheme());
System.out.println("Scheme-specific part = " + uri.getSchemeSpecificPart());
System.out.println("User info = " + uri.getUserInfo());
System.out.println("URI is absolute: " + uri.isAbsolute());
System.out.println("URI is opaque: " + uri.isOpaque());
}catch(URISyntaxException use){
use.printStackTrace();
}
}
}