Sfoglia il codice sorgente

committing Fido lab

chitraBegerhotta 6 anni fa
parent
commit
1a606c04e3

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

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 Vedi File

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

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

1
 <?xml version="1.0" encoding="UTF-8"?>
1
 <?xml version="1.0" encoding="UTF-8"?>
2
 <project version="4">
2
 <project version="4">
3
+  <component name="ExternalStorageConfigurationManager" enabled="true" />
3
   <component name="MavenProjectsManager">
4
   <component name="MavenProjectsManager">
4
     <option name="originalFiles">
5
     <option name="originalFiles">
5
       <list>
6
       <list>
7
       </list>
8
       </list>
8
     </option>
9
     </option>
9
   </component>
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
 </project>
14
 </project>

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

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 Vedi File

8
     <artifactId>ZCW-Fido-URLFetch</artifactId>
8
     <artifactId>ZCW-Fido-URLFetch</artifactId>
9
     <version>1.0-SNAPSHOT</version>
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
 </project>
20
 </project>

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

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 Vedi File


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