@Override public Map<String, Object> readAttributes( final Path path, final String attributes ) throws UnsupportedOperationException, NoSuchFileException, IllegalArgumentException, IOException, SecurityException { return Files.readAttributes( path, attributes ); }
/** * @throws IllegalArgumentException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#exists(java.nio.file.Path, java.nio.file.LinkOption...)">Original JavaDoc</a> */ public static boolean exists( final Path path, final LinkOption... options ) throws IllegalArgumentException, SecurityException { checkNotNull( "path", path ); try { readAttributes( path, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS ); 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#notExists(java.nio.file.Path, java.nio.file.LinkOption...)">Original JavaDoc</a> */ public static boolean notExists( final Path path, final LinkOption... options ) throws IllegalArgumentException, SecurityException { checkNotNull( "path", path ); try { readAttributes( path, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS ); return false; } catch ( NoSuchFileException x ) { return true; } catch ( Exception x ) { } return false; }
public static Object getAttribute( final Path path, final String attribute, final LinkOption... options ) throws UnsupportedOperationException, IllegalArgumentException, IOException, SecurityException { checkNotNull( "path", path ); checkNotEmpty( "attribute", attribute ); if ( attribute.indexOf( '*' ) >= 0 || attribute.indexOf( ',' ) >= 0 ) { throw new IllegalArgumentException( attribute ); } final Map<String, Object> map = readAttributes( path, attribute, options ); final String name; final int pos = attribute.indexOf( ':' ); if ( pos == -1 ) { name = attribute; } else { name = ( pos == attribute.length() ) ? "" : attribute.substring( pos + 1 ); } return map.get( name ); }
/** * @throws IllegalArgumentException * @throws IOException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#getLastModifiedTime(java.nio.file.Path, java.nio.file.LinkOption...)">Original JavaDoc</a> */ public static FileTime getLastModifiedTime( final Path path, final LinkOption... options ) throws IllegalArgumentException, IOException, SecurityException { checkNotNull( "path", path ); return readAttributes( path, BasicFileAttributes.class, options ).lastModifiedTime(); }
/** * @throws IllegalArgumentException * @throws IOException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#size(java.nio.file.Path)">Original JavaDoc</a> */ public static long size( final Path path ) throws IllegalArgumentException, IOException, SecurityException { checkNotNull( "path", path ); return readAttributes( path, BasicFileAttributes.class ).size(); }
/** * @throws IllegalArgumentException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#isSymbolicLink(java.nio.file.Path)">Original JavaDoc</a> */ public static boolean isSymbolicLink( final Path path ) throws IllegalArgumentException, SecurityException { checkNotNull( "path", path ); try { return readAttributes( path, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS ).isSymbolicLink(); } catch ( Exception ioe ) { } return false; }
/** * @throws IllegalAccessError * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#isRegularFile(java.nio.file.Path, java.nio.file.LinkOption...)">Original JavaDoc</a> */ public static boolean isRegularFile( final Path path, final LinkOption... options ) throws IllegalAccessError, SecurityException { checkNotNull( "path", path ); try { return readAttributes( path, BasicFileAttributes.class, options ).isRegularFile(); } catch ( IOException ioe ) { } return false; }
/** * @throws IllegalArgumentException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)">Original JavaDoc</a> */ public static boolean isDirectory( final Path path, final LinkOption... options ) throws IllegalArgumentException, SecurityException { checkNotNull( "path", path ); try { return readAttributes( path, BasicFileAttributes.class, options ).isDirectory(); } catch ( IOException ioe ) { } return false; }
@Override public Map<String, Object> readAttributes( final Path path, final String attributes ) throws UnsupportedOperationException, NoSuchFileException, IllegalArgumentException, IOException, SecurityException { checkNotNull( "path", path ); checkNotEmpty( "attributes", attributes ); final Properties original = new Properties( Files.readAttributes( path, attributes ) ); if ( attributes.equals( "*" ) && exists( dot( path ) ) ) { boolean isAttrHolder = path instanceof AttrHolder; if ( isAttrHolder && ( (AttrHolder) path ).getAttrStorage().getContent().size() > 0 ) { return ( (AttrHolder) path ).getAttrStorage().getAllContent(); } final Properties content = new Properties(); content.load( newInputStream( dot( path ) ) ); content.putAll( original ); if ( isAttrHolder ) { ( (AttrHolder) path ).getAttrStorage().loadContent( content ); } return content; } return original; }
BasicFileAttributes attrs = null; try { attrs = Files.readAttributes(file, BasicFileAttributes.class); } catch (IOException ex) { exc = ex;