how to set a timeout on URL.getContent()

Hi all,

I've got some code that calls an external API using URL.getContent(). Sometimes that external API is down and I'd like to force my system to respond very quickly (say within 5 seconds) and continue if it doesn't get a response.

Is there a way that I can specify a 5 second timeout on URL.getContent()?

Thanks,

-d

[354 byte] By [desau13a] at [2007-11-26 18:44:31]
# 1
Found it --URLConnection connection = URL.openConnection();connection.setReadTimeout(5000);content = connection.getContent();
desau13a at 2007-7-9 6:18:26 > top of Java-index,Core,Core APIs...