Java URL Value Check isJarFileURL(URL url)

Here you can find the source of isJarFileURL(URL url)

Description

Determine whether the given URL points to a jar file itself, that is, has protocol "file" and ends with the ".jar" extension.

License

Open Source License

Parameter

Parameter Description
url the URL to check

Return

whether the URL has been identified as a JAR file URL

Declaration

public static boolean isJarFileURL(URL url) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.net.URL;

public class Main {
    /** URL protocol for a file in the file system: "file" */
    public static final String URL_PROTOCOL_FILE = "file";
    /** File extension for a regular jar file: ".jar" */
    public static final String JAR_FILE_EXTENSION = ".jar";

    /**/*from   w  w  w .j a va  2s  . co  m*/
     * Determine whether the given URL points to a jar file itself,
     * that is, has protocol "file" and ends with the ".jar" extension.
     * @param url the URL to check
     * @return whether the URL has been identified as a JAR file URL
     * @since 4.1
     */
    public static boolean isJarFileURL(URL url) {
        return (URL_PROTOCOL_FILE.equals(url.getProtocol())
                && url.getPath().toLowerCase().endsWith(JAR_FILE_EXTENSION));
    }
}

Related

  1. isHttpURLAvailable(final String url)
  2. isInternetReachable(String url)
  3. isJar(URL url)
  4. isJarFile(URL url)
  5. isJarFile(URLConnection connection)
  6. isJarURL(URL url)
  7. isJarURL(URL url)
  8. isJarURL(URL url)
  9. isJarURL(URL url)