Jamez-s 6 lat temu
rodzic
commit
092b08a8e8

+ 1
- 1
.idea/compiler.xml Wyświetl plik

@@ -9,7 +9,7 @@
9 9
         <module name="ZCW-Fido-URLFetch" />
10 10
       </profile>
11 11
     </annotationProcessing>
12
-    <bytecodeTargetLevel>
12
+    <bytecodeTargetLevel target="8">
13 13
       <module name="ZCW-Fido-URLFetch" target="1.8" />
14 14
     </bytecodeTargetLevel>
15 15
   </component>

+ 3
- 1
.idea/misc.xml Wyświetl plik

@@ -7,5 +7,7 @@
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
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
11
+    <output url="file://$PROJECT_DIR$/classes" />
12
+  </component>
11 13
 </project>

+ 1
- 1
.idea/modules.xml Wyświetl plik

@@ -2,7 +2,7 @@
2 2
 <project version="4">
3 3
   <component name="ProjectModuleManager">
4 4
     <modules>
5
-      <module fileurl="file://$PROJECT_DIR$/.idea/ZCW-Fido-URLFetch.iml" filepath="$PROJECT_DIR$/.idea/ZCW-Fido-URLFetch.iml" />
5
+      <module fileurl="file://$PROJECT_DIR$/ZCW-Fido-URLFetch.iml" filepath="$PROJECT_DIR$/ZCW-Fido-URLFetch.iml" />
6 6
     </modules>
7 7
   </component>
8 8
 </project>

+ 1
- 1
.idea/vcs.xml Wyświetl plik

@@ -1,6 +1,6 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <project version="4">
3 3
   <component name="VcsDirectoryMappings">
4
-    <mapping directory="" vcs="Git" />
4
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
5 5
   </component>
6 6
 </project>

.idea/ZCW-Fido-URLFetch.iml → ZCW-Fido-URLFetch.iml Wyświetl plik

@@ -5,8 +5,6 @@
5 5
     <output-test url="file://$MODULE_DIR$/target/test-classes" />
6 6
     <content url="file://$MODULE_DIR$">
7 7
       <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
8
-      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
9
-      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
10 8
       <excludeFolder url="file://$MODULE_DIR$/target" />
11 9
     </content>
12 10
     <orderEntry type="inheritedJdk" />

+ 32
- 1
src/main/java/Main.java Wyświetl plik

@@ -1,7 +1,38 @@
1
+import java.io.IOException;
2
+import java.net.MalformedURLException;
3
+import java.net.URL;
4
+import java.net.URLConnection;
5
+import java.util.Scanner;
6
+
1 7
 public class Main {
2 8
     public static void main(String[] args) {
3
-        //ask for a url
9
+        System.out.println("Enter a url");
10
+
11
+        // ask for a url
12
+        Scanner scanner = new Scanner(System.in);
13
+        String url = scanner.nextLine().trim();
14
+        System.out.println("Fetching " + url);
15
+
4 16
         // fetch the url
17
+        String content = null;
18
+        URLConnection connection = null;
19
+
20
+        try {
21
+            connection = new URL("https://" + url).openConnection();
22
+
23
+            Scanner urlScanner = new Scanner(connection.getInputStream());
24
+            urlScanner.useDelimiter("\\Z");  //terminating line
25
+
26
+            content = urlScanner.next();
27
+
28
+        } catch (MalformedURLException e) {
29
+            e.printStackTrace();
30
+        } catch (IOException e) {
31
+            e.printStackTrace();
32
+        }catch ( Exception ex ) {
33
+            ex.printStackTrace();
34
+        }
5 35
         // print the url
36
+        System.out.println(content);
6 37
     }
7 38
 }

BIN
target/classes/Main.class Wyświetl plik