|
@@ -0,0 +1,32 @@
|
|
1
|
+import java.net.MalformedURLException;
|
|
2
|
+import java.net.URL;
|
|
3
|
+import java.net.URLConnection;
|
|
4
|
+import java.util.Scanner;
|
|
5
|
+
|
|
6
|
+public class Main {
|
|
7
|
+ public static void main(String[] args) {
|
|
8
|
+ Scanner scan = new Scanner(System.in);
|
|
9
|
+
|
|
10
|
+ System.out.println("enter URL: ");
|
|
11
|
+ String url = scan.nextLine();
|
|
12
|
+ System.out.println("fetching " + url);
|
|
13
|
+ String linkInput = null;
|
|
14
|
+ URLConnection connection = null;
|
|
15
|
+ try {
|
|
16
|
+ connection = new URL(url).openConnection();
|
|
17
|
+ Scanner urlScanner = new Scanner(connection.getInputStream());
|
|
18
|
+ urlScanner.useDelimiter("\\Z");
|
|
19
|
+
|
|
20
|
+ linkInput = urlScanner.next();
|
|
21
|
+ }
|
|
22
|
+ catch (MalformedURLException e) {
|
|
23
|
+ e.printStackTrace();
|
|
24
|
+
|
|
25
|
+ }
|
|
26
|
+ catch (Exception e){
|
|
27
|
+ e.printStackTrace();
|
|
28
|
+
|
|
29
|
+ }
|
|
30
|
+ System.out.println(linkInput);
|
|
31
|
+ }
|
|
32
|
+}
|