shakila 6 år sedan
förälder
incheckning
5254195520
6 ändrade filer med 29 tillägg och 9 borttagningar
  1. 3
    1
      .idea/misc.xml
  2. 1
    1
      .idea/modules.xml
  3. 1
    1
      .idea/vcs.xml
  4. 0
    2
      ZCW-Fido-URLFetch.iml
  5. 24
    4
      src/main/java/Main.java
  6. Binär
      target/classes/Main.class

+ 3
- 1
.idea/misc.xml Visa fil

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

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

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

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

+ 24
- 4
src/main/java/Main.java Visa fil

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

Binär
target/classes/Main.class Visa fil