Here you can find the source of isLocalFile(URI uri)
Parameter | Description |
---|---|
uri | the uri to check |
public static boolean isLocalFile(URI uri)
//package com.java2s; /*/*w w w . j a va2 s . c om*/ * Written by Dawid Kurzyniec and released to the public domain, as explained * at http://creativecommons.org/licenses/publicdomain */ import java.net.*; public class Main { /** * Checks if the URI points to the local file. * @param uri the uri to check * @return true if the URI points to a local file */ public static boolean isLocalFile(URI uri) { if (!uri.isAbsolute()) return false; if (uri.isOpaque()) return false; if (!"file".equalsIgnoreCase(uri.getScheme())) return false; if (uri.getAuthority() != null) return false; if (uri.getFragment() != null) return false; if (uri.getQuery() != null) return false; if ("".equals(uri.getPath())) return false; return true; } public static boolean isAbsolute(String path) { return (path.length() > 0 && path.charAt(0) == '/'); } }