< prev index next >

src/java.base/share/classes/java/nio/file/attribute/PosixFileAttributeView.java

Print this page




  57  * operating systems and file systems may provide additional permission bits
  58  * but access to these other bits is not defined by this class in this release.
  59  *
  60  * <p> <b>Usage Example:</b>
  61  * Suppose we need to print out the owner and access permissions of a file:
  62  * <pre>
  63  *     Path file = ...
  64  *     PosixFileAttributes attrs = Files.getFileAttributeView(file, PosixFileAttributeView.class)
  65  *         .readAttributes();
  66  *     System.out.format("%s %s%n",
  67  *         attrs.owner().getName(),
  68  *         PosixFilePermissions.toString(attrs.permissions()));
  69  * </pre>
  70  *
  71  * <h2> Dynamic Access </h2>
  72  * <p> Where dynamic access to file attributes is required, the attributes
  73  * supported by this attribute view are as defined by {@link
  74  * BasicFileAttributeView} and {@link FileOwnerAttributeView}, and in addition,
  75  * the following attributes are supported:
  76  * <blockquote>
  77  * <table border="1" cellpadding="8" summary="Supported attributes">


  78  *   <tr>
  79  *     <th> Name </th>
  80  *     <th> Type </th>
  81  *   </tr>


  82  *  <tr>
  83  *     <td> "permissions" </td>
  84  *     <td> {@link Set}&lt;{@link PosixFilePermission}&gt; </td>
  85  *   </tr>
  86  *   <tr>
  87  *     <td> "group" </td>
  88  *     <td> {@link GroupPrincipal} </td>
  89  *   </tr>

  90  * </table>
  91  * </blockquote>
  92  *
  93  * <p> The {@link Files#getAttribute getAttribute} method may be used to read
  94  * any of these attributes, or any of the attributes defined by {@link
  95  * BasicFileAttributeView} as if by invoking the {@link #readAttributes
  96  * readAttributes()} method.
  97  *
  98  * <p> The {@link Files#setAttribute setAttribute} method may be used to update
  99  * the file's last modified time, last access time or create time attributes as
 100  * defined by {@link BasicFileAttributeView}. It may also be used to update
 101  * the permissions, owner, or group-owner as if by invoking the {@link
 102  * #setPermissions setPermissions}, {@link #setOwner setOwner}, and {@link
 103  * #setGroup setGroup} methods respectively.
 104  *
 105  * <h2> Setting Initial Permissions </h2>
 106  * <p> Implementations supporting this attribute view may also support setting
 107  * the initial permissions when creating a file or directory. The
 108  * initial permissions are provided to the {@link Files#createFile createFile}
 109  * or {@link Files#createDirectory createDirectory} methods as a {@link




  57  * operating systems and file systems may provide additional permission bits
  58  * but access to these other bits is not defined by this class in this release.
  59  *
  60  * <p> <b>Usage Example:</b>
  61  * Suppose we need to print out the owner and access permissions of a file:
  62  * <pre>
  63  *     Path file = ...
  64  *     PosixFileAttributes attrs = Files.getFileAttributeView(file, PosixFileAttributeView.class)
  65  *         .readAttributes();
  66  *     System.out.format("%s %s%n",
  67  *         attrs.owner().getName(),
  68  *         PosixFilePermissions.toString(attrs.permissions()));
  69  * </pre>
  70  *
  71  * <h2> Dynamic Access </h2>
  72  * <p> Where dynamic access to file attributes is required, the attributes
  73  * supported by this attribute view are as defined by {@link
  74  * BasicFileAttributeView} and {@link FileOwnerAttributeView}, and in addition,
  75  * the following attributes are supported:
  76  * <blockquote>
  77  * <table class="striped">
  78  * <caption style="display:none">Supported attributes</caption>
  79  * <thead>
  80  *   <tr>
  81  *     <th> Name </th>
  82  *     <th> Type </th>
  83  *   </tr>
  84  * </thead>
  85  * <tbody>
  86  *  <tr>
  87  *     <td> "permissions" </td>
  88  *     <td> {@link Set}&lt;{@link PosixFilePermission}&gt; </td>
  89  *   </tr>
  90  *   <tr>
  91  *     <td> "group" </td>
  92  *     <td> {@link GroupPrincipal} </td>
  93  *   </tr>
  94  * </tbody>
  95  * </table>
  96  * </blockquote>
  97  *
  98  * <p> The {@link Files#getAttribute getAttribute} method may be used to read
  99  * any of these attributes, or any of the attributes defined by {@link
 100  * BasicFileAttributeView} as if by invoking the {@link #readAttributes
 101  * readAttributes()} method.
 102  *
 103  * <p> The {@link Files#setAttribute setAttribute} method may be used to update
 104  * the file's last modified time, last access time or create time attributes as
 105  * defined by {@link BasicFileAttributeView}. It may also be used to update
 106  * the permissions, owner, or group-owner as if by invoking the {@link
 107  * #setPermissions setPermissions}, {@link #setOwner setOwner}, and {@link
 108  * #setGroup setGroup} methods respectively.
 109  *
 110  * <h2> Setting Initial Permissions </h2>
 111  * <p> Implementations supporting this attribute view may also support setting
 112  * the initial permissions when creating a file or directory. The
 113  * initial permissions are provided to the {@link Files#createFile createFile}
 114  * or {@link Files#createDirectory createDirectory} methods as a {@link


< prev index next >