HttpURLConnection timeout question
Posted
by Malachi
on Stack Overflow
See other posts from Stack Overflow
or by Malachi
Published on 2010-05-10T01:55:45Z
Indexed on
2010/05/10
1:58 UTC
Read the original article
Hit count: 498
I want to return false if the URL takes more then 5 seconds to connect - how is this possible using java? Here is the code I am using to check if the URL is valid
HttpURLConnection.setFollowRedirects(false);
HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection();
con.setRequestMethod("HEAD");
return (con.getResponseCode() == HttpURLConnection.HTTP_OK);
© Stack Overflow or respective owner