jdk/src/java.base/share/classes/java/nio/file/Files.java
changeset 37346 931e55c1287d
parent 36511 9d0388c6b336
child 39657 90ff5a56fe54
equal deleted inserted replaced
37345:9cb6e1141bdb 37346:931e55c1287d
    74 import java.util.Spliterator;
    74 import java.util.Spliterator;
    75 import java.util.Spliterators;
    75 import java.util.Spliterators;
    76 import java.util.function.BiPredicate;
    76 import java.util.function.BiPredicate;
    77 import java.util.stream.Stream;
    77 import java.util.stream.Stream;
    78 import java.util.stream.StreamSupport;
    78 import java.util.stream.StreamSupport;
       
    79 
       
    80 import sun.nio.fs.AbstractFileSystemProvider;
    79 
    81 
    80 /**
    82 /**
    81  * This class consists exclusively of static methods that operate on files,
    83  * This class consists exclusively of static methods that operate on files,
    82  * directories, or other types of files.
    84  * directories, or other types of files.
    83  *
    85  *
  2191      *          In the case of the default provider, and a security manager is
  2193      *          In the case of the default provider, and a security manager is
  2192      *          installed, its {@link SecurityManager#checkRead(String) checkRead}
  2194      *          installed, its {@link SecurityManager#checkRead(String) checkRead}
  2193      *          method denies read access to the file.
  2195      *          method denies read access to the file.
  2194      */
  2196      */
  2195     public static boolean isDirectory(Path path, LinkOption... options) {
  2197     public static boolean isDirectory(Path path, LinkOption... options) {
       
  2198         if (options.length == 0) {
       
  2199             FileSystemProvider provider = provider(path);
       
  2200             if (provider instanceof AbstractFileSystemProvider)
       
  2201                 return ((AbstractFileSystemProvider)provider).isDirectory(path);
       
  2202         }
       
  2203 
  2196         try {
  2204         try {
  2197             return readAttributes(path, BasicFileAttributes.class, options).isDirectory();
  2205             return readAttributes(path, BasicFileAttributes.class, options).isDirectory();
  2198         } catch (IOException ioe) {
  2206         } catch (IOException ioe) {
  2199             return false;
  2207             return false;
  2200         }
  2208         }
  2228      *          In the case of the default provider, and a security manager is
  2236      *          In the case of the default provider, and a security manager is
  2229      *          installed, its {@link SecurityManager#checkRead(String) checkRead}
  2237      *          installed, its {@link SecurityManager#checkRead(String) checkRead}
  2230      *          method denies read access to the file.
  2238      *          method denies read access to the file.
  2231      */
  2239      */
  2232     public static boolean isRegularFile(Path path, LinkOption... options) {
  2240     public static boolean isRegularFile(Path path, LinkOption... options) {
       
  2241         if (options.length == 0) {
       
  2242             FileSystemProvider provider = provider(path);
       
  2243             if (provider instanceof AbstractFileSystemProvider)
       
  2244                 return ((AbstractFileSystemProvider)provider).isRegularFile(path);
       
  2245         }
       
  2246 
  2233         try {
  2247         try {
  2234             return readAttributes(path, BasicFileAttributes.class, options).isRegularFile();
  2248             return readAttributes(path, BasicFileAttributes.class, options).isRegularFile();
  2235         } catch (IOException ioe) {
  2249         } catch (IOException ioe) {
  2236             return false;
  2250             return false;
  2237         }
  2251         }
  2383      *          read access to the file.
  2397      *          read access to the file.
  2384      *
  2398      *
  2385      * @see #notExists
  2399      * @see #notExists
  2386      */
  2400      */
  2387     public static boolean exists(Path path, LinkOption... options) {
  2401     public static boolean exists(Path path, LinkOption... options) {
       
  2402         if (options.length == 0) {
       
  2403             FileSystemProvider provider = provider(path);
       
  2404             if (provider instanceof AbstractFileSystemProvider)
       
  2405                 return ((AbstractFileSystemProvider)provider).exists(path);
       
  2406         }
       
  2407 
  2388         try {
  2408         try {
  2389             if (followLinks(options)) {
  2409             if (followLinks(options)) {
  2390                 provider(path).checkAccess(path);
  2410                 provider(path).checkAccess(path);
  2391             } else {
  2411             } else {
  2392                 // attempt to read attributes without following links
  2412                 // attempt to read attributes without following links