List of utility methods to do URL Value Check
boolean | isURL(String token) Returns true if the input token is a URL, and false otherwise. try { URL url = new URL(token); return true; } catch (MalformedURLException e) { return false; |
boolean | isUrl(String value) is Url try { new java.net.URL(value); } catch (MalformedURLException e) { return false; return true; |
boolean | isURLAccessible(String URL) Finds out whether a URL returns HTTP OK or not. try { HttpURLConnection.setFollowRedirects(false); HttpURLConnection connection = (HttpURLConnection) new URL(URL).openConnection(); connection.setRequestMethod("HEAD"); return (connection.getResponseCode() == HttpURLConnection.HTTP_OK); } catch (Exception e) { return false; |
boolean | isURLAvailable(String url, int timeout) is URL Available try { return isURLAvailable(new URL(url), timeout); } catch (MalformedURLException e) { e.printStackTrace(); return false; |
boolean | isUrlAvailable(URL url, Proxy proxy) Checks whether the specified URL points to a valid resource. if (url != null) { if (url.getProtocol().equalsIgnoreCase("http") || url.getProtocol().equalsIgnoreCase("https")) { HttpURLConnection.setFollowRedirects(true); HttpURLConnection conn = null; if (proxy != null) { conn = (HttpURLConnection) url.openConnection(proxy); } else { conn = (HttpURLConnection) url.openConnection(); ... |
boolean | isUrlDownWithRetries(String url, long timeoutMs, long retryDelayMs) Returns true if the URL status code is not 200. return getUrlContentWithRetries(url, timeoutMs, retryDelayMs, true) == null;
|
boolean | isUrlExists(String url) is Url Exists try { URL urlObject = new URL(url); HttpURLConnection huc = (HttpURLConnection) urlObject.openConnection(); huc.setRequestMethod("HEAD"); huc.connect(); return huc.getResponseCode() == 200; } catch (IOException ignored) { return false; |
boolean | isURLExists(String URLName) is URL Exists try { if (!URLName.toUpperCase().contains("HTTP")) URLName = "http://" + URLName; URL url = new URL(URLName); System.setProperty("java.net.useSystemProxies", "true"); HttpURLConnection urlConn = (HttpURLConnection) url.openConnection(); urlConn.setConnectTimeout(9000); urlConn.setReadTimeout(9000); ... |
boolean | isUrlInJar(URL url) is Url In Jar return url == null ? false : url.toString().startsWith("jar:"); |
boolean | isUrlResponding(String url) is Url Responding try { return isUrlResponding(new URL(url)); } catch (MalformedURLException e) { return false; |