Java Utililty Methods URL Value Check

List of utility methods to do URL Value Check

Description

The list of methods to do URL Value Check are organized into topic(s).

Method

booleanisHttpUrl(URL url)
Returns true if the specified url protocol is http.
String protocol = url.getProtocol();
return url != null && (HTTP_PROTOCOL.equals(protocol) || HTTPS_PROTOCOL.equals(protocol));
booleanisHttpUrl(URL url)
is Http Url
return url != null && "http".equalsIgnoreCase(url.getProtocol());
booleanisHttpURLAvailable(final String url)
Executes an HTTP GET Request to the given URL, using a one second connect timeout and read timeout.
return getHttpReturnCode(url) == HttpURLConnection.HTTP_OK;
booleanisInternetReachable(String url)
is Internet Reachable
try {
    InetAddress address = InetAddress.getByName(url);
    if (address == null) {
        return false;
} catch (UnknownHostException e) {
    return false;
return true;
booleanisJar(URL url)
is Jar
if (url.getProtocol() != null && url.getProtocol().length() > 0) {
    if (url.getProtocol().equalsIgnoreCase("jar")) {
        return true;
return url.getPath().endsWith(".jar");
booleanisJarFile(URL url)
is Jar File
URI uri;
try {
    uri = url.toURI();
} catch (URISyntaxException e) {
    throw new IOException(e);
String scheme = uri.getScheme();
if (scheme.equals("jar")) {
...
booleanisJarFile(URLConnection connection)
is Jar File
return connection.getURL().toString().endsWith(JAR_EXTENSION);
booleanisJarFileURL(URL url)
Determine whether the given URL points to a jar file itself, that is, has protocol "file" and ends with the ".jar" extension.
return (URL_PROTOCOL_FILE.equals(url.getProtocol())
        && url.getPath().toLowerCase().endsWith(JAR_FILE_EXTENSION));
booleanisJarURL(URL url)
is Jar URL
return URL_PROTOCOL_JAR.equals(url.getProtocol());
booleanisJarURL(URL url)
Determine whether the given URL points to a resource in a jar file, that is, has protocol "jar", "zip", "wsjar" or "code-source".
String protocol = url.getProtocol();
return (URL_PROTOCOL_JAR.equals(protocol) || URL_PROTOCOL_ZIP.equals(protocol)
        || URL_PROTOCOL_WSJAR.equals(protocol)
        || (URL_PROTOCOL_CODE_SOURCE.equals(protocol) && url.getPath().contains(JAR_URL_SEPARATOR)));