FileOwnerAttributeView
Stay organized with collections
Save and categorize content based on your preferences.
Known Indirect Subclasses
AclFileAttributeView |
A file attribute view that supports reading or updating a file's Access
Control Lists (ACL) or file owner attributes. |
PosixFileAttributeView |
A file attribute view that provides a view of the file attributes commonly
associated with files on file systems used by operating systems that implement
the Portable Operating System Interface (POSIX) family of standards. |
|
A file attribute view that supports reading or updating the owner of a file.
This file attribute view is intended for file system implementations that
support a file attribute that represents an identity that is the owner of
the file. Often the owner of a file is the identity of the entity that
created the file.
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
.
Public Methods
public
abstract
UserPrincipal
getOwner
()
Read the file owner.
It it implementation specific if the file owner can be a group
.
public
abstract
String
name
()
Returns the name of the attribute view. Attribute views of this type
have the name "owner"
.
Returns
- the name of the attribute view
public
abstract
void
setOwner
(UserPrincipal owner)
Updates the file owner.
It it 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.
Throws
IOException |
if an I/O error occurs, or the owner parameter is a
group and this implementation does not support setting the owner
to a group |
SecurityException |
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.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eFileOwnerAttributeView\u003c/code\u003e provides methods to get and set the owner of a file.\u003c/p\u003e\n"],["\u003cp\u003eIt's primarily used for file systems that support file ownership as an attribute.\u003c/p\u003e\n"],["\u003cp\u003eThis view can be accessed via the attribute name \u003ccode\u003e"owner"\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eWhile it may be possible to set a group as the owner, it is recommended to only use user principals for consistency.\u003c/p\u003e\n"],["\u003cp\u003eThe view is implemented by \u003ccode\u003eAclFileAttributeView\u003c/code\u003e and \u003ccode\u003ePosixFileAttributeView\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# FileOwnerAttributeView\n\npublic interface **FileOwnerAttributeView** implements [FileAttributeView](../../../../../reference/java/nio/file/attribute/FileAttributeView.html) \n\n|---|---|---|\n| Known Indirect Subclasses [AclFileAttributeView](../../../../../reference/java/nio/file/attribute/AclFileAttributeView.html), [PosixFileAttributeView](../../../../../reference/java/nio/file/attribute/PosixFileAttributeView.html) |--------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [AclFileAttributeView](../../../../../reference/java/nio/file/attribute/AclFileAttributeView.html) | A file attribute view that supports reading or updating a file's Access Control Lists (ACL) or file owner attributes. | | [PosixFileAttributeView](../../../../../reference/java/nio/file/attribute/PosixFileAttributeView.html) | A file attribute view that provides a view of the file attributes commonly associated with files on file systems used by operating systems that implement the Portable Operating System Interface (POSIX) family of standards. | |||\n\nA file attribute view that supports reading or updating the owner of a file.\nThis file attribute view is intended for file system implementations that\nsupport a file attribute that represents an identity that is the owner of\nthe file. Often the owner of a file is the identity of the entity that\ncreated the file.\n\nThe [getOwner](../../../../../reference/java/nio/file/attribute/FileOwnerAttributeView.html#getOwner()) or [setOwner](../../../../../reference/java/nio/file/attribute/FileOwnerAttributeView.html#setOwner(java.nio.file.attribute.UserPrincipal)) methods may\nbe used to read or update the owner of the file.\n\nThe [getAttribute](../../../../../reference/java/nio/file/Files.html#getAttribute(java.nio.file.Path,%20java.lang.String,%20java.nio.file.LinkOption...)) and\n[setAttribute](../../../../../reference/java/nio/file/Files.html#setAttribute(java.nio.file.Path,%20java.lang.String,%20java.lang.Object,%20java.nio.file.LinkOption...)) methods may also be\nused to read or update the owner. In that case, the owner attribute is\nidentified by the name `\"owner\"`, and the value of the attribute is\na [UserPrincipal](../../../../../reference/java/nio/file/attribute/UserPrincipal.html). \n\n### Public Method Summary\n\n|-----------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [UserPrincipal](../../../../../reference/java/nio/file/attribute/UserPrincipal.html) | [getOwner](../../../../../reference/java/nio/file/attribute/FileOwnerAttributeView.html#getOwner())() Read the file owner. |\n| abstract [String](../../../../../reference/java/lang/String.html) | [name](../../../../../reference/java/nio/file/attribute/FileOwnerAttributeView.html#name())() Returns the name of the attribute view. |\n| abstract void | [setOwner](../../../../../reference/java/nio/file/attribute/FileOwnerAttributeView.html#setOwner(java.nio.file.attribute.UserPrincipal))([UserPrincipal](../../../../../reference/java/nio/file/attribute/UserPrincipal.html) owner) Updates the file owner. |\n\n### Inherited Method Summary\n\nFrom interface [java.nio.file.attribute.AttributeView](../../../../../reference/java/nio/file/attribute/AttributeView.html) \n\n|-------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|\n| abstract [String](../../../../../reference/java/lang/String.html) | [name](../../../../../reference/java/nio/file/attribute/AttributeView.html#name())() Returns the name of the attribute view. |\n\nPublic Methods\n--------------\n\n#### public abstract [UserPrincipal](../../../../../reference/java/nio/file/attribute/UserPrincipal.html)\n**getOwner**\n()\n\nRead the file owner.\n\nIt it implementation specific if the file owner can be a [group](../../../../../reference/java/nio/file/attribute/GroupPrincipal.html). \n\n##### Returns\n\n- the file owner \n\n##### Throws\n\n| [IOException](../../../../../reference/java/io/IOException.html) | if an I/O error occurs |\n| [SecurityException](../../../../../reference/java/lang/SecurityException.html) | In the case of the default provider, a security manager is installed, and it denies [RuntimePermission](../../../../../reference/java/lang/RuntimePermission.html)(\"accessUserInformation\") or its [checkRead](../../../../../reference/java/lang/SecurityManager.html#checkRead(java.lang.String)) method denies read access to the file. |\n|--------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n\n#### public abstract [String](../../../../../reference/java/lang/String.html)\n**name**\n()\n\nReturns the name of the attribute view. Attribute views of this type\nhave the name `\"owner\"`. \n\n##### Returns\n\n- the name of the attribute view \n\n#### public abstract void\n**setOwner**\n([UserPrincipal](../../../../../reference/java/nio/file/attribute/UserPrincipal.html) owner)\n\nUpdates the file owner.\n\nIt it implementation specific if the file owner can be a [group](../../../../../reference/java/nio/file/attribute/GroupPrincipal.html). To ensure consistent and correct behavior\nacross platforms it is recommended that this method should only be used\nto set the file owner to a user principal that is not a group. \n\n##### Parameters\n\n| owner | the new file owner |\n|-------|--------------------|\n\n##### Throws\n\n| [IOException](../../../../../reference/java/io/IOException.html) | if an I/O error occurs, or the `owner` parameter is a group and this implementation does not support setting the owner to a group |\n| [SecurityException](../../../../../reference/java/lang/SecurityException.html) | In the case of the default provider, a security manager is installed, and it denies [RuntimePermission](../../../../../reference/java/lang/RuntimePermission.html)(\"accessUserInformation\") or its [checkWrite](../../../../../reference/java/lang/SecurityManager.html#checkWrite(java.lang.String)) method denies write access to the file. |\n|--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|"]]