/Users/lyon/j4p/src/net/web/UrlUtils.java

1    package net.web; 
2     
3    import java.io.BufferedReader; 
4    import java.io.IOException; 
5    import java.io.InputStreamReader; 
6    import java.net.URL; 
7    import java.util.Vector; 
8     
9    public class UrlUtils { 
10     public static void printVector(Vector v) { 
11       for (int i = 0; i < v.size(); i++) { 
12         System.out.println(v.elementAt(i)); 
13       } 
14     } 
15    
16     public static Vector lookForJobs(String keyword) { 
17       return 
18           getUrl 
19           //("http://jobsearch.monster.com/jobsearch.asp?q="+keyword); 
20           ("http://trading.etrade.com/cgi-bin/gx.cgi/Applogic+IPOCurrent"); 
21     } 
22    
23     public static void main(String args[]) { 
24         net.proxy.Proxy.setSoeProxy(); 
25       printVector(lookForJobs("java")); 
26     } 
27     public static String []  getUrlString(String urlString){ 
28         Vector v = getUrl(urlString); 
29         String s[] = new String [v.size()]; 
30         v.copyInto(s); 
31         return s; 
32     } 
33     public static Vector getUrl(String _URLString) { 
34       Vector contents = new Vector(); 
35       BufferedReader in = null; 
36       try { 
37         URL URLString = new URL(_URLString); 
38         in = new BufferedReader(new 
39                 InputStreamReader(URLString.openStream())); 
40    
41         String line; 
42         while (null != (line = in.readLine())) 
43           contents.addElement(line); 
44    
45       } catch (Exception e) { 
46         e.printStackTrace(); 
47       } finally { 
48         try { 
49           if (in != null) in.close(); 
50         } catch (IOException e) { 
51           e.printStackTrace(); 
52         } 
53       } 
54       return contents; 
55     } 
56   }