Secure iNet Factory

com.jscape.inet.util
Class TimedURLConnection

java.lang.Object
  extended by com.jscape.inet.util.TimedURLConnection

public class TimedURLConnection
extends java.lang.Object

Implements methods for opening an InputStream or OutputStream on a URLConnection within a desired timeout. *

Example Usage:

 int timeout = 5000; // 5 second timeout
 try
 {
   URL url = new URL("http://www.myserver.com");
   URLConnection conn = url.openConnection();
   InputStream in = TimedURLConnection.getInputStream(conn,timeout);
 }
 catch(Exception ioe)
 {
   // handle exception
 }
 


Method Summary
static java.io.InputStream getInputStream(java.net.URLConnection conn, int delay)
          Gets InputStream from a URLConnection within a specified timeout.
static java.io.OutputStream getOutputStream(java.net.URLConnection conn, int delay)
          Gets OutputStream from a URLConnection within a specified timeout.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getOutputStream

public static java.io.OutputStream getOutputStream(java.net.URLConnection conn,
                                                   int delay)
                                            throws java.io.IOException
Gets OutputStream from a URLConnection within a specified timeout.

Parameters:
conn - the URLConnection
delay - timeout in milliseconds
Throws:
java.io.IOException - timeout is reached or other I/O error occurs

getInputStream

public static java.io.InputStream getInputStream(java.net.URLConnection conn,
                                                 int delay)
                                          throws java.io.InterruptedIOException,
                                                 java.io.IOException
Gets InputStream from a URLConnection within a specified timeout.

Parameters:
conn - the URLConnection
delay - timeout in milliseconds
Throws:
java.io.IOException - timeout is reached or other I/O error occurs
java.io.InterruptedIOException

Secure iNet Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved