Java URL Value Check isFileURL(URL url)

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

Description

Determine whether the given URL points to a resource in the file system, that is, has protocol "file" or "vfs".

License

LGPL

Parameter

Parameter Description
url the URL to check

Return

whether the URL has been identified as a file system URL

Declaration

public static boolean isFileURL(URL url) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

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";
    /** URL protocol for a JBoss VFS resource: "vfs" */
    public static final String URL_PROTOCOL_VFS = "vfs";

    /**//from  w  w  w  .  j a  v  a2  s.  c o  m
     * Determine whether the given URL points to a resource in the file system,
     * that is, has protocol "file" or "vfs".
     * @param url the URL to check
     * @return whether the URL has been identified as a file system URL
     */
    public static boolean isFileURL(URL url) {
        String protocol = url.getProtocol();
        return (URL_PROTOCOL_FILE.equals(protocol) || protocol.startsWith(URL_PROTOCOL_VFS));
    }
}

Related

  1. isFileSpecified(URL url)
  2. isFileURL(String path)
  3. isFileURL(URL repositoryURL)
  4. isFileURL(URL url)
  5. isFileURL(URL url)
  6. isFileURL(URL url)
  7. isFileURL(URL url)
  8. isFileURL(URL url)
  9. isFileUrl(URL url)