/** * @throws IllegalArgumentException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#isExecutable(java.nio.file.Path)">Original JavaDoc</a> */ public static boolean isExecutable( final Path path ) throws IllegalArgumentException, SecurityException { checkNotNull( "path", path ); try { providerOf( path ).checkAccess( path, EXECUTE ); return true; } catch ( Exception x ) { } return false; }
/** * @throws IllegalArgumentException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#isReadable(java.nio.file.Path)">Original JavaDoc</a> */ public static boolean isReadable( final Path path ) throws IllegalArgumentException, SecurityException { checkNotNull( "path", path ); try { providerOf( path ).checkAccess( path, READ ); return true; } catch ( Exception x ) { } return false; }
/** * @throws IllegalArgumentException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#isWritable(java.nio.file.Path)">Original JavaDoc</a> */ public static boolean isWritable( final Path path ) throws IllegalArgumentException, SecurityException { checkNotNull( "path", path ); try { providerOf( path ).checkAccess( path, WRITE ); return true; } catch ( Exception x ) { } return false; }
public static Path createDirectories( final Path dir, final FileAttribute<?>... attrs ) throws UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { checkNotNull( "dir", dir ); final Path absoluteDir = dir.toAbsolutePath(); if ( !notExists( absoluteDir ) ) { throw new FileAlreadyExistsException( absoluteDir.toString() ); } Path parent = absoluteDir.getParent(); while ( parent != null ) { try { providerOf( parent ).checkAccess( parent ); break; } catch ( NoSuchFileException x ) { } parent = parent.getParent(); } if ( parent == null ) { throw new IOException( "Root directory does not exist" ); } // create directories Path child = parent; for ( final Path name : parent.relativize( dir ) ) { child = child.resolve( name ); providerOf( child ).createDirectory( child, attrs ); } return dir; }