Alfredo Castillo 6 лет назад
Родитель
Сommit
64d17f746c
6 измененных файлов: 29 добавлений и 6 удалений
  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
    1
      src/main/java/Main.java
  6. Двоичные данные
      target/classes/Main.class

+ 3
- 1
.idea/misc.xml Просмотреть файл

7
       </list>
7
       </list>
8
     </option>
8
     </option>
9
   </component>
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
 </project>
13
 </project>

+ 1
- 1
.idea/modules.xml Просмотреть файл

2
 <project version="4">
2
 <project version="4">
3
   <component name="ProjectModuleManager">
3
   <component name="ProjectModuleManager">
4
     <modules>
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
     </modules>
6
     </modules>
7
   </component>
7
   </component>
8
 </project>
8
 </project>

+ 1
- 1
.idea/vcs.xml Просмотреть файл

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="VcsDirectoryMappings">
3
   <component name="VcsDirectoryMappings">
4
-    <mapping directory="" vcs="Git" />
4
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
   </component>
5
   </component>
6
 </project>
6
 </project>

.idea/ZCW-Fido-URLFetch.iml → ZCW-Fido-URLFetch.iml Просмотреть файл

5
     <output-test url="file://$MODULE_DIR$/target/test-classes" />
5
     <output-test url="file://$MODULE_DIR$/target/test-classes" />
6
     <content url="file://$MODULE_DIR$">
6
     <content url="file://$MODULE_DIR$">
7
       <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
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" />
8
       <excludeFolder url="file://$MODULE_DIR$/target" />
11
     </content>
9
     </content>
12
     <orderEntry type="inheritedJdk" />
10
     <orderEntry type="inheritedJdk" />

+ 24
- 1
src/main/java/Main.java Просмотреть файл

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

Двоичные данные
target/classes/Main.class Просмотреть файл