io
Class HttpHandler

java.lang.Object
  extended by io.HttpHandler
All Implemented Interfaces:
java.lang.Runnable

public class HttpHandler
extends java.lang.Object
implements java.lang.Runnable

A class, implemented as a Thread, for dealing with HTTP requests.
The class can be used in two ways:

Author:
Peter Hlavac

Constructor Summary
HttpHandler(java.lang.String strUrl)
          Creates a thread for calling an URL asynchronously.
 
Method Summary
static byte[] getByteArrayFromURL(java.lang.String url)
          Returns the stream from a successfull HTTP request
static java.lang.String getResponseFromURL(java.lang.String url)
          Returns the response from a successfull HTTP request as a string
 void run()
          This method sends an asynchronous HTTP GET request to the url, that was set in the constructor.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpHandler

public HttpHandler(java.lang.String strUrl)
Creates a thread for calling an URL asynchronously.

Parameters:
strUrl - the URL to send the HTTP request
Method Detail

run

public void run()
This method sends an asynchronous HTTP GET request to the url, that was set in the constructor.

Specified by:
run in interface java.lang.Runnable

getResponseFromURL

public static java.lang.String getResponseFromURL(java.lang.String url)
                                           throws java.io.IOException
Returns the response from a successfull HTTP request as a string

Parameters:
url - the url where to get the response from
Returns:
the response from the given url converted to a string
Throws:
java.io.IOException - thrown if resource is not found

getByteArrayFromURL

public static byte[] getByteArrayFromURL(java.lang.String url)
                                  throws java.io.IOException
Returns the stream from a successfull HTTP request

Parameters:
url - the url where to get the response from
Returns:
the response stream from the given url converted to a string
Throws:
java.io.IOException - thrown if resource is not found