William Simkins 6 anos atrás
pai
commit
38d0b57673
2 arquivos alterados com 33 adições e 0 exclusões
  1. 32
    0
      .idea/Main.java
  2. 1
    0
      .idea/misc.xml

+ 32
- 0
.idea/Main.java Ver arquivo

@@ -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 Ver arquivo

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