Browse Source

committing Fido lab

chitraBegerhotta 6 years ago
parent
commit
1a606c04e3

+ 0
- 15
.idea/ZCW-Fido-URLFetch.iml View File

@@ -1,15 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3
-  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
4
-    <output url="file://$MODULE_DIR$/target/classes" />
5
-    <output-test url="file://$MODULE_DIR$/target/test-classes" />
6
-    <content url="file://$MODULE_DIR$">
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
-      <excludeFolder url="file://$MODULE_DIR$/target" />
11
-    </content>
12
-    <orderEntry type="inheritedJdk" />
13
-    <orderEntry type="sourceFolder" forTests="false" />
14
-  </component>
15
-</module>

+ 0
- 3
.idea/compiler.xml View File

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

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

@@ -1,5 +1,6 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <project version="4">
3
+  <component name="ExternalStorageConfigurationManager" enabled="true" />
3 4
   <component name="MavenProjectsManager">
4 5
     <option name="originalFiles">
5 6
       <list>
@@ -7,4 +8,7 @@
7 8
       </list>
8 9
     </option>
9 10
   </component>
11
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
12
+    <output url="file://$PROJECT_DIR$/out" />
13
+  </component>
10 14
 </project>

+ 0
- 8
.idea/modules.xml View File

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

+ 9
- 1
pom.xml View File

@@ -8,5 +8,13 @@
8 8
     <artifactId>ZCW-Fido-URLFetch</artifactId>
9 9
     <version>1.0-SNAPSHOT</version>
10 10
 
11
-    
11
+    <dependencies>
12
+    <dependency>
13
+        <groupId>commons-io</groupId>
14
+        <artifactId>commons-io</artifactId>
15
+        <version>2.6</version>
16
+    </dependency>
17
+    </dependencies>
18
+
19
+
12 20
 </project>

+ 38
- 0
src/main/java/io/zipcode/URLReader.java View File

@@ -0,0 +1,38 @@
1
+package io.zipcode;
2
+
3
+import org.apache.commons.io.IOUtils;
4
+
5
+import java.io.InputStream;
6
+import java.net.URL;
7
+import java.net.URLConnection;
8
+import java.util.Scanner;
9
+
10
+public class URLReader {
11
+
12
+    public static void main(String[] args) {
13
+        Scanner input = new Scanner(System.in);
14
+        System.out.println("Please enter url: ");
15
+        String strUrl = input.nextLine();
16
+
17
+        String body = "";
18
+
19
+        try{
20
+            URL url = new URL(strUrl);
21
+
22
+        URLConnection con = url.openConnection();
23
+        InputStream in = con.getInputStream();
24
+        String encoding = con.getContentEncoding();  // ** WRONG: should use "con.getContentType()" instead but
25
+        // it returns something like "text/html; charset=UTF-8" so this value must be parsed to extract the actual encoding
26
+        encoding = encoding == null ? "UTF-8" : encoding;
27
+         body = IOUtils.toString(in, encoding);
28
+        } catch (Exception e){
29
+
30
+            System.out.println("Exception is " + e );
31
+        }
32
+
33
+
34
+
35
+        System.out.println(body);
36
+    }
37
+
38
+}

BIN
target/classes/io/zipcode/URLReader.class View File


+ 0
- 0
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst View File