replace constant with named constant

master
ManuSayure 2017-03-01 07:39:43 -03:00 committed by melvinzhang
parent 5c14ec844e
commit 7da6835d7f
1 changed files with 2 additions and 1 deletions

View File

@ -57,6 +57,7 @@ public final class UrlHelper {
* Quickly checks to see whether URL is reachable. * Quickly checks to see whether URL is reachable.
*/ */
public static boolean isUrlValid(final URL url) { public static boolean isUrlValid(final URL url) {
final int timeout= 2000; // time, in milliseconds, used for open a link referenced by this URLConnection.
if (url == null) if (url == null)
return false; return false;
@ -64,7 +65,7 @@ public final class UrlHelper {
try { try {
final HttpURLConnection huc = (HttpURLConnection) url.openConnection(); final HttpURLConnection huc = (HttpURLConnection) url.openConnection();
huc.setRequestMethod("HEAD"); huc.setRequestMethod("HEAD");
huc.setConnectTimeout(2000); huc.setConnectTimeout(timeout); // Using constant named
final int responseCode = huc.getResponseCode(); final int responseCode = huc.getResponseCode();
return responseCode == HttpURLConnection.HTTP_OK; return responseCode == HttpURLConnection.HTTP_OK;