Preventing eternal hang

I

Ike

Is there a way I can wrap the following in such a manner such that if no
value is returned by after X seconds, the method throws an IOException ?

private InputStream getFromServlet( URLConnection uc) throws
java.io.IOException {
return uc.getInputStream();
}

I know in 1.5 this is built into getInputStream, but I need compatibility to
lower-version JVMs. Thanks, Ike
 
A

Andrea Desole

I would put it in a separate thread. You can interrupt this thread after
a timeout. It should work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top