|
@@ -1,7 +1,28 @@
|
|
1
|
+import jdk.nashorn.api.scripting.URLReader;
|
|
2
|
+
|
|
3
|
+import java.util.Scanner;
|
|
4
|
+import java.net.*;
|
|
5
|
+import java.io.*;
|
|
6
|
+
|
1
|
7
|
public class Main {
|
2
|
|
- public static void main(String[] args) {
|
|
8
|
+ public static void main(String[] args) throws Exception{
|
3
|
9
|
//ask for a url
|
|
10
|
+ System.out.println("What website would you like to fetch?");
|
|
11
|
+ Scanner scanner = new Scanner(System.in);
|
|
12
|
+ String input = scanner.nextLine();
|
|
13
|
+
|
|
14
|
+ URLReader(input);
|
|
15
|
+ }
|
|
16
|
+ public static void URLReader(String input) throws Exception{
|
|
17
|
+
|
4
|
18
|
// fetch the url
|
|
19
|
+ URL oracle = new URL(input);
|
|
20
|
+ BufferedReader in = new BufferedReader(
|
|
21
|
+ new InputStreamReader(oracle.openStream()));
|
5
|
22
|
// print the url
|
6
|
|
- }
|
|
23
|
+ String inputLine;
|
|
24
|
+ while ((inputLine = in.readLine()) != null)
|
|
25
|
+ System.out.print(inputLine);
|
|
26
|
+ in.close();
|
|
27
|
+ }
|
7
|
28
|
}
|