模块 java.base

接口 FileOwnerAttributeView

所有父级接口:
AttributeView , FileAttributeView
所有已知的子接口:
AclFileAttributeView , PosixFileAttributeView

public interface FileOwnerAttributeView extends FileAttributeView
支持读取或更新文件所有者的文件属性视图。此文件属性视图适用于支持表示文件所有者身份的文件属性的文件系统实现。文件的所有者通常是创建文件的实体的身份。

getOwner setOwner 方法可用于读取或更新文件的所有者。

getAttribute setAttribute 方法也可用于读取或更新所有者。在这种情况下,所有者属性由名称 "owner" 标识,属性的值是 UserPrincipal

自从:
1.7
  • 方法详情

    • name

      String  name()
      返回属性视图的名称。这种类型的属性视图的名称为 "owner"
      指定者:
      name 在接口 AttributeView
      返回:
      属性视图的名称
    • getOwner

      UserPrincipal  getOwner() throws IOException
      读取文件所有者。

      如果文件所有者可以是 group ,则它是特定于实现的。

      返回:
      文件所有者
      抛出:
      IOException - 如果发生 I/O 错误
      SecurityException - 在默认提供程序的情况下,安装了安全管理器,它拒绝 RuntimePermission ("accessUserInformation") 或其 checkRead 方法拒绝对文件的读取访问。
    • setOwner

      void setOwner(UserPrincipal  owner) throws IOException
      更新文件所有者。

      如果文件所有者可以是 group ,则它是特定于实现的。为确保跨平台行为一致且正确,建议仅使用此方法将文件所有者设置为非组的用户主体。

      参数:
      owner - 新的文件所有者
      抛出:
      IOException - 如果发生 I/O 错误,或者 owner 参数是一个组并且此实现不支持将所有者设置为组
      SecurityException - 在默认提供程序的情况下,安装了安全管理器,它拒绝 RuntimePermission ("accessUserInformation") 或其 checkWrite 方法拒绝对文件的写访问。