AttributeView
, FileAttributeView
AclFileAttributeView
, PosixFileAttributeView
public interface FileOwnerAttributeView extends FileAttributeView
The getOwner
or setOwner
methods may be used to read or update the owner of the file.
The getAttribute
and setAttribute
methods may also be used to read or update the owner. In that case, the owner attribute is identified by the name "owner"
, and the value of the attribute is a UserPrincipal
.
Modifier and Type | Method | Description |
---|---|---|
UserPrincipal |
getOwner() |
Read the file owner. |
String |
name() |
Returns the name of the attribute view. |
void |
setOwner |
Updates the file owner. |
String name()
"owner"
.name
in interface AttributeView
UserPrincipal getOwner() throws IOException
It is implementation specific if the file owner can be a group
.
IOException
- if an I/O error occursSecurityException
- In the case of the default provider, a security manager is installed, and it denies RuntimePermission
("accessUserInformation")
or its checkRead
method denies read access to the file.void setOwner(UserPrincipal owner) throws IOException
It is implementation specific if the file owner can be a group
. To ensure consistent and correct behavior across platforms it is recommended that this method should only be used to set the file owner to a user principal that is not a group.
owner
- the new file ownerIOException
- if an I/O error occurs, or the owner
parameter is a group and this implementation does not support setting the owner to a groupSecurityException
- In the case of the default provider, a security manager is installed, and it denies RuntimePermission
("accessUserInformation")
or its checkWrite
method denies write access to the file.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/nio/file/attribute/FileOwnerAttributeView.html