William Simkins 6 years ago
parent
commit
38d0b57673
2 changed files with 33 additions and 0 deletions
  1. 32
    0
      .idea/Main.java
  2. 1
    0
      .idea/misc.xml

+ 32
- 0
.idea/Main.java View File

@@ -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
+}

+ 1
- 0
.idea/misc.xml View File

@@ -7,4 +7,5 @@
7 7
       </list>
8 8
     </option>
9 9
   </component>
10
+  <component name="ProjectRootManager" version="2" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
10 11
 </project>