Java URI Value Check isFile(final URI uri)

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

Description

Is the URI representing a file??

License

Open Source License

Parameter

Parameter Description
uri a parameter

Return

True if the URI is representing a file

Declaration

public static boolean isFile(final URI uri) 

Method Source Code

//package com.java2s;
/*//from  w w  w . j  a  v  a  2 s .c  o  m
 * 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 file??
     *
     * @param uri
     * @return True if the URI is representing a file
     */
    public static boolean isFile(final URI uri) {
        if ((uri != null) && (uri.getScheme() != null)) {
            return uri.getScheme().equalsIgnoreCase("file");
        }

        return false;
    }

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

        return false;
    }
}

Related

  1. isBase(URI base, URI uri)
  2. isDefaultPort(URI uri)
  3. isDirectory(URI orig)
  4. isExtensionUri(final URI uri)
  5. isFile(final URI uri)
  6. isFile(URI uri)
  7. isFile(URI uri)
  8. isFileSystemAvailable(File file, URI topLevelResource)
  9. isFileUri(String uri)