List of utility methods to do URL Value Check
boolean | isValidURL(String url) Checks if the URL is valid or not. try { URL urlObj = new URL(url); String host = urlObj.getHost(); assert !host.isEmpty(); assert host.contains("."); } catch (MalformedURLException e) { return false; } catch (AssertionError e) { ... |
boolean | isValidURL(String url) is Valid URL try { HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); conn.setConnectTimeout(3000); conn.connect(); conn.disconnect(); return conn.getResponseCode() >= 200 && conn.getResponseCode() < 300; } catch (Exception e) { e.printStackTrace(); ... |
boolean | isValidURL(String url) is Valid URL if (url.length() < 10) return false; url = url.trim(); if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("ftp://")) { String host = null; try { host = getHostName(url); } catch (MalformedURLException e) { ... |
boolean | isValidUrl(String url) Check whether provided url string is a valid java java.net.URL try { if (Strings.isNullOrEmpty(url)) { return false; new URL(url); return true; } catch (MalformedURLException e) { return false; ... |
boolean | isValidURL(String URL_String) Opens up a connection with the given URL and returns true if the response code is 200 (success) try { URL url = new URL(URL_String); url.toURI(); } catch (MalformedURLException e) { return false; } catch (URISyntaxException e) { return false; return true; |
boolean | isValidURL(String urlStr) is Valid URL return parseURI(urlStr) != null;
|
boolean | isValidURL(String urlStr) Checks whether the given string is a valid URL. if (urlStr == null) { return false; try { URI uri = new URI(urlStr); if (uri.getScheme() == null) { return false; return uri.getScheme().equals("http") || uri.getScheme().equals("https"); } catch (URISyntaxException e) { return false; |
URL | isValidURL(String urlString) is Valid URL try { return new URL(urlString); } catch (Exception e) { return null; |
boolean | isValidUrl(URI uri) is Valid Url try { uri.toURL(); } catch (MalformedURLException | IllegalArgumentException e) { return false; return true; |
boolean | isValidURL(URL url) is Valid URL try { if (isHttpUrl(url.toString())) { URLConnection connection = url.openConnection(); if (connection instanceof HttpURLConnection) { HttpURLConnection httpConnection = (HttpURLConnection) connection; httpConnection.setConnectTimeout(1000); httpConnection.connect(); int response = httpConnection.getResponseCode(); ... |