Skip to content

Commit e41cc71

Browse files
authored
Create Fetch.java
1 parent 71201a7 commit e41cc71

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Fetch.java

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import java.net.URLConnection;
2+
import java.util.Scanner;
3+
import java.net.URL;
4+
5+
class Fetch {
6+
public static void main(String [] args) throws Exception {
7+
String content = null;
8+
URLConnection connection = null;
9+
connection = new URL("http://www.google.com").openConnection();
10+
Scanner scanner = new Scanner(connection.getInputStream());
11+
scanner.useDelimiter("\\Z");
12+
content = scanner.next();
13+
scanner.close();
14+
System.out.print(content);
15+
}
16+
}

0 commit comments

Comments
 (0)