/Users/lyon/j4p/src/net/web/Browser.java
|
1 package net.web;
2
3 import net.proxy.Proxy;
4
5 import java.io.InputStreamReader;
6
7 public class Browser {
8 public static void main(String args[]) {
9 //print(
10 // getUrl("http://www.docjava.com"));
11 Proxy.setSoeProxy();
12 gui.html.HtmlViewer hv =
13 new gui.html.HtmlViewer();
14 String s =
15 Browser.toString("http://lyon.fairfield.edu");
16 hv.setHtml(s);
17 hv.setPlainText(s);
18 }
19
20 public static String toString(String url) {
21 java.util.Vector v = getUrl(url);
22 String s = "\n";
23 for (int i = 0; i < v.size(); i++)
24 s = s + v.elementAt(i);
25 return s;
26 }
27
28 public static java.util.Vector getUrl(String
29 _urlString) {
30 try {
31 java.net.URL url
32 = new java.net.URL(_urlString);
33 System.out.println("url="
34 + url);
35 return
36 getUrl(url);
37 } catch (Exception e) {
38 e.printStackTrace();
39 return null;
40 }
41 }
42
43 public static java.util.Vector getUrl(
44 java.net.URL url)
45 throws java.io.IOException {
46 java.util.Vector v = new java.util.Vector();
47 java.io.BufferedReader br
48 = new java.io.BufferedReader(
49 new InputStreamReader(
50 url.openStream()));
51 for (String l = br.readLine();
52 l != null;
53 l = br.readLine())
54 v.addElement(l);
55 return v;
56 }
57
58 public static void print(java.util.Vector v) {
59 System.out.println("Vector print");
60 for (int i = 0; i < v.size(); i++)
61 System.out.println(v.elementAt(i));
62 }
63 }
64
65