public interface FileOwnerAttributeView extends FileAttributeView
getOwner或setOwner方法可用于读取或更新文件的所有者。
getAttribute和setAttribute方法也可用于读取或更新所有者。 在这种情况下,所有者属性由名称"owner" ,属性值为UserPrincipal 。
| Modifier and Type | Method and Description |
|---|---|
UserPrincipal |
getOwner()
阅读文件所有者。
|
String |
name()
返回属性视图的名称。
|
void |
setOwner(UserPrincipal owner)
更新文件所有者。
|
String name()
"owner" 。
name在界面
AttributeView
UserPrincipal getOwner() throws IOException
它的实现具体如果文件所有者可以是一个group 。
IOException - 如果发生I / O错误
SecurityException - 在默认提供程序的情况下,安装了一个安全管理器,它拒绝RuntimePermission ("accessUserInformation")或其checkRead方法拒绝对该文件的读取访问。
void setOwner(UserPrincipal owner) throws IOException
它的实现具体如果文件所有者可以是一个group 。 为了确保跨平台的一致和正确的行为,建议仅使用此方法将文件所有者设置为不是组的用户主体。
owner - 新的文件所有者
IOException - 如果发生I / O错误,或
owner参数是一个组,并且此实现不支持将所有者设置为组
SecurityException - 在默认提供程序的情况下,安装了一个安全管理器,它拒绝RuntimePermission ("accessUserInformation")或其checkWrite方法拒绝对该文件的写入访问。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.