-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathUrlTest.java
More file actions
38 lines (21 loc) · 797 Bytes
/
UrlTest.java
File metadata and controls
38 lines (21 loc) · 797 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
30
31
32
33
34
35
36
37
38
package ex;
import java.net.MalformedURLException;
import java.net.URL;
public class UrlTest {
public static void main(String[] args) {
String urlStr = "https://sports.news.naver.com/news.nhn?oid=410&aid=0000791096";
try {
URL url = new URL(urlStr);
System.out.println("Protocol : " + url.getProtocol());
System.out.println("Host Name : " + url.getHost());
System.out.println("Port Num : " + url.getPort());
System.out.println("Default Port Num : " + url.getDefaultPort());
System.out.println("Query : " + url.getQuery());
System.out.println("Path : " + url.getPath() );
System.out.println("File : " + url.getFile());
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}