replace constant with named constant
parent
5c14ec844e
commit
7da6835d7f
|
@ -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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue