|
@@ -0,0 +1,48 @@
|
|
1
|
+package rocks.zipcode.fido;
|
|
2
|
+
|
|
3
|
+import java.io.BufferedReader;
|
|
4
|
+import java.io.InputStreamReader;
|
|
5
|
+import java.net.URL;
|
|
6
|
+
|
|
7
|
+public class FidoFetch {
|
|
8
|
+ private URL oracle;
|
|
9
|
+
|
|
10
|
+ public FidoFetch(URL oracle) throws Exception {
|
|
11
|
+ this.oracle = oracle;
|
|
12
|
+ this.fetchToOutput(this.oracle);
|
|
13
|
+ }
|
|
14
|
+
|
|
15
|
+ public FidoFetch() {
|
|
16
|
+ }
|
|
17
|
+
|
|
18
|
+ public void fetchToOutput(URL url) throws Exception {
|
|
19
|
+
|
|
20
|
+ // open a stream for the URL
|
|
21
|
+ BufferedReader in = new BufferedReader(
|
|
22
|
+ new InputStreamReader(url.openStream()));
|
|
23
|
+
|
|
24
|
+ String inputLine;
|
|
25
|
+ // while there is stuff in the stream, read a line at a time and print it out.
|
|
26
|
+ while ((inputLine = in.readLine()) != null)
|
|
27
|
+ System.out.println(inputLine);
|
|
28
|
+ in.close();
|
|
29
|
+
|
|
30
|
+ }
|
|
31
|
+
|
|
32
|
+ public static void main(String[] args) {
|
|
33
|
+ String urlString = "";
|
|
34
|
+
|
|
35
|
+ // get the url from the commandline
|
|
36
|
+ if (args.length > 0) {
|
|
37
|
+ urlString = args[0];
|
|
38
|
+ }
|
|
39
|
+
|
|
40
|
+ FidoFetch f = new FidoFetch();
|
|
41
|
+ try {
|
|
42
|
+ f.fetchToOutput(new URL(urlString));
|
|
43
|
+ } catch (Exception e) {
|
|
44
|
+ e.printStackTrace();
|
|
45
|
+ }
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+}
|