List of utility methods to do URL Value Check
boolean | checkUrl(final String link) check Url try { URL url = new URL(link); URLConnection conn = url.openConnection(); conn.connect(); return true; } catch (Exception e) { return false; ... |
int | checkURL(String _url) check URL int ans = 0; int dots = (numberOfDots(_url)); if (dots >= 3) ans += dots * 5; ans += suspiciousURL(_url) * 2; if (hasIP(_url)) { ans += 80; if (hasEmbeddedDomain(_url)) ans += 80; if (outOfPositionTLD(_url)) ans += 40; ans += senstiveWords(_url) * 10; return ans; |
boolean | checkUrl(String inputUrlString) check Url URL url = new URL(inputUrlString); return checkUrl(url); |
int | checkUrl(String url, int timeout) check Url try { URL url2 = null; HttpURLConnection conn = null; url2 = new URL(url); conn = (HttpURLConnection) url2.openConnection(); long len = conn.getContentLength(); conn.setConnectTimeout(timeout); return conn.getResponseCode(); ... |
URL | checkURL(URL check) check URL URL result = null; if (check != null) { try { InputStream is = check.openStream(); is.close(); result = check; } catch (IOException e) { return result; |
void | checkUrl(URL url, URL baseUrl) check Url if (baseUrl.getHost() == null) { throw new RuntimeException("base URL is null"); if (!baseUrl.getHost().equalsIgnoreCase(url.getHost())) { throw new RuntimeException("Domain of URL " + url + " doesn't match base URL " + baseUrl); |
String | checkURLAvailable(String targetUrl) check URL Available try { URL url = new URL(targetUrl); URLConnection urlConnection = url.openConnection(); HttpURLConnection.setFollowRedirects(true); HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection; httpURLConnection.setRequestMethod("HEAD"); if (httpURLConnection.getResponseCode() >= MIN_HTTP_VALID_CODE && httpURLConnection.getResponseCode() < MAX_HTTP_VALID_CODE) { ... |
boolean | checkUrlImage(final String url) Blocking. try { final HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); return connection.getResponseCode() == 200 && connection.getContentType() != null && connection.getContentType().contains("image"); } catch (Exception e) { return false; |
boolean | checkURLStatus(String pURL) check URL Status URL url = null; HttpURLConnection conn = null; try { url = new URL(pURL); conn = (HttpURLConnection) url.openConnection(); conn.connect(); return true; } catch (MalformedURLException e) { ... |
boolean | checkURLValidProtocol(URL url) Returns true if the supplied URL is using one of the formats supported by open-delta - the supported formats are http, ftp and file. return (url.getProtocol().equalsIgnoreCase("http") || (url.getProtocol().equalsIgnoreCase("ftp") || (url.getProtocol().equalsIgnoreCase("file")))); |