net.spy.net
Class HTTPFetch

java.lang.Object
  extended bynet.spy.net.HTTPFetch

public class HTTPFetch
extends Object

Oversimplified HTTP document fetcher.


Constructor Summary
HTTPFetch(String u)
          Deprecated. don't pass Strings, pass URLs
HTTPFetch(String u, Map head)
          Deprecated. don't pass Strings, pass URLs
HTTPFetch(URL u)
          Get an HTTPFetch instance for the given URL.
HTTPFetch(URL u, Map head)
          Get an HTTPFetch instance for the given URL and headers.
 
Method Summary
 String getData()
          Return the contents of the URL as a whole string.
 List getLines()
          Get a vector containing the individual lines of the document returned from the URL.
 String getStrippedData()
          Return the contents of the URL with the HTML tags stripped out.
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTTPFetch

public HTTPFetch(String u)
          throws MalformedURLException
Deprecated. don't pass Strings, pass URLs

Create a new HTTPFetch object for a given string representation of a URL.

Parameters:
u - String representation of the URL we'll be connecting to.
Throws:
MalformedURLException - Thrown if the URL cannot be parsed.

HTTPFetch

public HTTPFetch(String u,
                 Map head)
          throws MalformedURLException
Deprecated. don't pass Strings, pass URLs

Create a new HTTPFetch object for a given string representation of a URL, including a Map describing extra headers to add.

Parameters:
u - String representation of the URL we'll be connecting to.
head - Map containing headers to set.
Throws:
MalformedURLException - Thrown if the URL cannot be parsed.

HTTPFetch

public HTTPFetch(URL u)
Get an HTTPFetch instance for the given URL.

Parameters:
u - the URL to fetch

HTTPFetch

public HTTPFetch(URL u,
                 Map head)
Get an HTTPFetch instance for the given URL and headers.

Parameters:
u - URL to fetch
head - Map containing the headers to fetch
Method Detail

getLines

public List getLines()
              throws Exception
Get a vector containing the individual lines of the document returned from the URL.

Throws:
Exception - thrown when something fails.

getData

public String getData()
               throws IOException
Return the contents of the URL as a whole string.

Returns:
the contents from the URL as a String
Throws:
IOException - if there is a problem accessing the URL

getStrippedData

public String getStrippedData()
                       throws Exception
Return the contents of the URL with the HTML tags stripped out.

Throws:
Exception - thrown when something fails.

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception