Skip to content

Commit 14436cd

Browse files
authored
persecuted woman which brought forth the man child
And when the dragon saw that he was cast unto the earth, he persecuted the woman which brought forth the man child. (Revelation 12:13)
1 parent 211eeed commit 14436cd

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
2+
//And when the dragon saw that he was cast unto the earth, he persecuted the woman which brought forth the man child. (Revelation 12:13)
3+
4+
package com.javarush.task.task40.task4011;
5+
6+
import java.io.IOException;
7+
import java.net.MalformedURLException;
8+
import java.net.URL;
9+
10+
/*
11+
Свойства URL
12+
*/
13+
14+
public class Solution {
15+
public static void main(String[] args) throws IOException {
16+
decodeURLString("https://www.amrood.com/index.htm?language=en#j2se");
17+
}
18+
19+
public static void decodeURLString(String s) {
20+
try {
21+
URL url = new URL(s);
22+
System.out.println(url.getProtocol());
23+
System.out.println(url.getAuthority());
24+
System.out.println(url.getFile());
25+
System.out.println(url.getHost());
26+
System.out.println(url.getPath());
27+
System.out.println(url.getPort());
28+
System.out.println(url.getDefaultPort());
29+
System.out.println(url.getQuery());
30+
System.out.println(url.getRef());
31+
} catch ( MalformedURLException e){
32+
33+
System.out.println(String.format("Parameter %s is not a valid URL", s));
34+
}
35+
}
36+
}
37+
38+
/*
39+
Свойства URL
40+
41+
Метод decodeURLString должен принимать URL ссылку в виде строки и выводить ее свойства на экран:
42+
43+
- protocol
44+
45+
- authority
46+
47+
- file
48+
49+
- host
50+
51+
- path
52+
53+
- port
54+
55+
- default port
56+
57+
- query
58+
59+
- ref
60+
61+
62+
63+
Если переданная строка не является валидной URL ссылкой, на экран должно быть выведено сообщение формата: "Parameter s is not a valid URL.", где s - полученная в качестве параметра строка.
64+
65+
66+
67+
P.S. Парсить строку не нужно, создай объект типа URL и вызови необходимые тебе методы.
68+
69+
70+
71+
72+
73+
Требования:
74+
75+
1. В методе decodeURLString должен быть создан новый объект типа URL.
76+
77+
2. На экран должно быть выведено свойство protocol ссылки полученной в качестве параметра.
78+
79+
3. На экран должно быть выведено свойство authority ссылки полученной в качестве параметра.
80+
81+
4. На экран должно быть выведено свойство file ссылки полученной в качестве параметра.
82+
83+
5. На экран должно быть выведено свойство host ссылки полученной в качестве параметра.
84+
85+
6. На экран должно быть выведено свойство path ссылки полученной в качестве параметра.
86+
87+
7. На экран должно быть выведено свойство port ссылки полученной в качестве параметра.
88+
89+
8. На экран должно быть выведено свойство default port ссылки полученной в качестве параметра.
90+
91+
9. На экран должно быть выведено свойство query ссылки полученной в качестве параметра.
92+
93+
10. На экран должно быть выведено свойство ref ссылки полученной в качестве параметра.
94+
95+
11. Метод decodeURLString должен выводить сообщение об ошибке на экран для некорректных URL ссылок.
96+
*/

0 commit comments

Comments
 (0)