< prev index next >

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

Print this page




 173      * {@code src.remaining()}. The sequence of bytes is transferred from the
 174      * buffer starting at index {@code p}, where {@code p} is the buffer's
 175      * position. Upon return, the buffer's position will be equal to {@code
 176      * p + n}, where {@code n} is the number of bytes transferred; its limit
 177      * will not have changed.
 178      *
 179      * <p> If an attribute of the given name already exists then its value is
 180      * replaced. If the attribute does not exist then it is created. If it
 181      * implementation specific if a test to check for the existence of the
 182      * attribute and the creation of attribute are atomic with respect to other
 183      * file system activities.
 184      *
 185      * <p> Where there is insufficient space to store the attribute, or the
 186      * attribute name or value exceed an implementation specific maximum size
 187      * then an {@code IOException} is thrown.
 188      *
 189      * <p> <b>Usage Example:</b>
 190      * Suppose we want to write a file's MIME type as a user-defined attribute:
 191      * <pre>
 192      *    UserDefinedFileAttributeView view =
 193      *        FIles.getFileAttributeView(path, UserDefinedFileAttributeView.class);
 194      *    view.write("user.mimetype", Charset.defaultCharset().encode("text/html"));
 195      * </pre>
 196      *
 197      * @param   name
 198      *          The attribute name
 199      * @param   src
 200      *          The buffer containing the attribute value
 201      *
 202      * @return  The number of bytes written, possibly zero
 203      *
 204      * @throws  IOException
 205      *          If an I/O error occurs
 206      * @throws  SecurityException
 207      *          In the case of the default provider, a security manager is
 208      *          installed, and it denies {@link
 209      *          RuntimePermission}{@code ("accessUserDefinedAttributes")}
 210      *          or its {@link SecurityManager#checkWrite(String) checkWrite}
 211      *          method denies write access to the file.
 212      */
 213     int write(String name, ByteBuffer src) throws IOException;


 173      * {@code src.remaining()}. The sequence of bytes is transferred from the
 174      * buffer starting at index {@code p}, where {@code p} is the buffer's
 175      * position. Upon return, the buffer's position will be equal to {@code
 176      * p + n}, where {@code n} is the number of bytes transferred; its limit
 177      * will not have changed.
 178      *
 179      * <p> If an attribute of the given name already exists then its value is
 180      * replaced. If the attribute does not exist then it is created. If it
 181      * implementation specific if a test to check for the existence of the
 182      * attribute and the creation of attribute are atomic with respect to other
 183      * file system activities.
 184      *
 185      * <p> Where there is insufficient space to store the attribute, or the
 186      * attribute name or value exceed an implementation specific maximum size
 187      * then an {@code IOException} is thrown.
 188      *
 189      * <p> <b>Usage Example:</b>
 190      * Suppose we want to write a file's MIME type as a user-defined attribute:
 191      * <pre>
 192      *    UserDefinedFileAttributeView view =
 193      *        Files.getFileAttributeView(path, UserDefinedFileAttributeView.class);
 194      *    view.write("user.mimetype", Charset.defaultCharset().encode("text/html"));
 195      * </pre>
 196      *
 197      * @param   name
 198      *          The attribute name
 199      * @param   src
 200      *          The buffer containing the attribute value
 201      *
 202      * @return  The number of bytes written, possibly zero
 203      *
 204      * @throws  IOException
 205      *          If an I/O error occurs
 206      * @throws  SecurityException
 207      *          In the case of the default provider, a security manager is
 208      *          installed, and it denies {@link
 209      *          RuntimePermission}{@code ("accessUserDefinedAttributes")}
 210      *          or its {@link SecurityManager#checkWrite(String) checkWrite}
 211      *          method denies write access to the file.
 212      */
 213     int write(String name, ByteBuffer src) throws IOException;
< prev index next >