Java URI Value Check isJar(final URI uri)

Here you can find the source of isJar(final URI uri)

Description

Is the URI representing a JAR file??

License

Open Source License

Parameter

Parameter Description
uri a parameter

Return

True if the URI is representing a JAR file

Declaration

public static boolean isJar(final URI uri) 

Method Source Code

//package com.java2s;
/*/*from w w w . j a  v  a  2 s  .  c  om*/
 * Copyright (c) 2014 Stephan D. Cote' - All rights reserved.
 * 
 * This program and the accompanying materials are made available under the 
 * terms of the MIT License which accompanies this distribution, and is 
 * available at http://creativecommons.org/licenses/MIT/
 *
 * Contributors:
 *   Stephan D. Cote 
 *      - Initial concept and initial implementation
 */

import java.net.URI;

import java.net.URL;

public class Main {
    /**
     * Is the URI representing a JAR file??
     *
     *
     * @param uri
     * @return True if the URI is representing a JAR file
     */
    public static boolean isJar(final URI uri) {
        if ((uri != null) && (uri.getScheme() != null)) {
            return uri.getScheme().equalsIgnoreCase("jar");
        }

        return false;
    }

    /**
     * Is the URL representing a JAR file??
     *
     *
     * @param url
     * @return True if the URL is representing a JAR file
     */
    public static boolean isJar(final URL url) {
        if ((url != null) && (url.getProtocol() != null)) {
            return url.getProtocol().equalsIgnoreCase("jar");
        }

        return false;
    }
}

Related

  1. isFileURI(URI uri)
  2. isFileUri(URI uri)
  3. isFtp(URI uri)
  4. isHostDnsName(URI uri)
  5. isIRODSURIScheme(final URI irodsURI)
  6. isJarFile(final URI uri)
  7. isLocal(final URI uri)
  8. isLocal(final URI uri)
  9. isLocalFile(URI uri)