Creating timed URL connections

Top  Previous  Next

To create a timed URL connection you may use the TimedURLConnection#getInputStream method passing in a java.net.URLConnection and timeout as arguments.  A java.io.IOException will be thrown if an input stream cannot be obtained within the defined timeout.

 

Example

 

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

}





Home | Company | Products | Solutions | Purchase | Support | Services | Blog

© 2021 JSCAPE LLC