|
@@ -1,7 +1,33 @@
|
|
1
|
+import java.io.BufferedReader;
|
|
2
|
+import java.io.IOException;
|
|
3
|
+import java.io.InputStreamReader;
|
|
4
|
+import java.net.MalformedURLException;
|
|
5
|
+import java.net.URL;
|
|
6
|
+import java.net.URLConnection;
|
|
7
|
+import java.sql.SQLOutput;
|
|
8
|
+import java.util.Scanner;
|
|
9
|
+
|
1
|
10
|
public class Main {
|
2
|
|
- public static void main(String[] args) {
|
|
11
|
+ public static void main(String[] args) throws IOException {
|
|
12
|
+
|
3
|
13
|
//ask for a url
|
|
14
|
+ Scanner input = new Scanner(System.in);
|
|
15
|
+ System.out.println("Enter a URL without the http:// part but including the dot whatever part");
|
|
16
|
+ URL url= new URL("https://" + input.nextLine());
|
|
17
|
+
|
4
|
18
|
// fetch the url
|
|
19
|
+ URLConnection yc = url.openConnection();
|
|
20
|
+ BufferedReader in = new BufferedReader(new InputStreamReader(
|
|
21
|
+ yc.getInputStream()));
|
|
22
|
+ String inputLine;
|
|
23
|
+
|
5
|
24
|
// print the url
|
|
25
|
+ while ((inputLine = in.readLine()) != null)
|
|
26
|
+ System.out.println(inputLine);
|
|
27
|
+ in.close();
|
|
28
|
+
|
|
29
|
+ }
|
|
30
|
+
|
6
|
31
|
}
|
7
|
|
-}
|
|
32
|
+
|
|
33
|
+
|