org.xnap.net
Class HttpConnection

java.lang.Object
  extended by org.xnap.net.HttpConnection

public class HttpConnection
extends java.lang.Object

This class provides a convenience wrapper for the HttpURLConnection class.


Constructor Summary
HttpConnection()
          Constructs a http connection.
 
Method Summary
 void close()
          Closes the connection.
 void connect(java.lang.String location)
          Establishes a connection to location.
 void connect(java.net.URL url)
          Establishes a connection to url.
 java.io.InputStream getInputStream()
          Returns the associated input stream.
 java.lang.String nextLine()
          Reads and returns the next line from the input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpConnection

public HttpConnection()
Constructs a http connection. No action is taken.

Method Detail

connect

public void connect(java.net.URL url)
             throws java.io.IOException
Establishes a connection to url.

Parameters:
url - the url to connect to
Throws:
java.io.IOException - thrown if the connection fails

connect

public void connect(java.lang.String location)
             throws java.io.IOException
Establishes a connection to location.

Parameters:
location - the url to connect to
Throws:
java.io.IOException - thrown if the connection fails

close

public void close()
Closes the connection.


getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Returns the associated input stream. The connection needs to be established prior to invoking this method.

Throws:
java.io.IOException
See Also:
connect(URL)

nextLine

public java.lang.String nextLine()
Reads and returns the next line from the input stream. The connection is automatically closed if the end of the stream is reached.

Returns:
null, if the end of the stream is reached or an exception occurs


Copyright © 2001-2005 XNap Team. All Rights Reserved.