Spec-Zone .ru
спецификации, руководства, описания, API
|
|
Java™ Platform Standard Ed. 7 DRAFT ea-b118 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.nio.file.attribute.Attributes
public final class Attributes extends Object
This class consists exclusively of static methods that operate on or return
the attributes of files or file stores. These methods provide for convenient
use of the attribute-views
defined in this package.
Modifier and Type | Method and Description |
---|---|
static List<AclEntry> |
getAcl(FileRef file)
Reads a file's Access Control List (ACL). |
static UserPrincipal |
getOwner(FileRef file)
Returns the owner of a file. |
static BasicFileAttributes |
readBasicFileAttributes(FileRef file,
LinkOption... options)
Reads the basic file attributes of a file. |
static DosFileAttributes |
readDosFileAttributes(FileRef file,
LinkOption... options)
Reads the DOS file attributes of a file. |
static FileStoreSpaceAttributes |
readFileStoreSpaceAttributes(FileStore store)
Reads the space attributes of a file store. |
static PosixFileAttributes |
readPosixFileAttributes(FileRef file,
LinkOption... options)
Reads the POSIX file attributes of a file. |
static void |
setAcl(FileRef file,
List<AclEntry> acl)
Updates a file's Access Control List (ACL). |
static void |
setLastAccessTime(FileRef file,
FileTime lastAccessTime)
Updates a file's last access time attribute. |
static void |
setLastModifiedTime(FileRef file,
FileTime lastModifiedTime)
Updates a file's last modified time attribute. |
static void |
setOwner(FileRef file,
UserPrincipal owner)
Updates the file owner. |
static void |
setPosixFilePermissions(FileRef file,
Set<PosixFilePermission> perms)
Sets a file's POSIX permissions. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static BasicFileAttributes readBasicFileAttributes(FileRef file, LinkOption... options) throws IOException
The options
array may be used to indicate how symbolic links
are handled for the case that the file is a symbolic link. By default,
symbolic links are followed and the file attributes of the final target
of the link are read. If the option NOFOLLOW_LINKS
is present then symbolic links are not followed and so
the method returns the file attributes of the symbolic link itself.
This option should be used where there is a need to determine if a
file is a symbolic link:
boolean isSymbolicLink = Attributes.readBasicFileAttributes(file, NOFOLLOW_LINKS).isSymbolicLink();
It is implementation specific if all file attributes are read as an atomic operation with respect to other file system operations.
file
- A file reference that locates the fileoptions
- Options indicating how symbolic links are handledIOException
- If an I/O error occursSecurityException
- In the case of the default provider, the security manager's checkRead
method is invoked
to check read access to fileBasicFileAttributeView.readAttributes()
public static PosixFileAttributes readPosixFileAttributes(FileRef file, LinkOption... options) throws IOException
The file
parameter locates a file that supports the PosixFileAttributeView
. This file attribute view provides access to a
subset 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. It is implementation
specific if all file attributes are read as an atomic operation with
respect to other file system operations.
The options
array may be used to indicate how symbolic links
are handled for the case that the file is a symbolic link. By default,
symbolic links are followed and the file attributes of the final target
of the link are read. If the option NOFOLLOW_LINKS
is present then symbolic links are not followed and so
the method returns the file attributes of the symbolic link itself.
file
- A file reference that locates the fileoptions
- Options indicating how symbolic links are handledUnsupportedOperationException
- If the PosixFileAttributeView
is not availableIOException
- If an I/O error occursSecurityException
- In the case of the default provider, and a security manager is
installed, it denies RuntimePermission
("accessUserInformation")
or its checkRead
method
denies read access to the file.PosixFileAttributeView.readAttributes()
public static DosFileAttributes readDosFileAttributes(FileRef file, LinkOption... options) throws IOException
The file
parameter locates a file that supports the DosFileAttributeView
. This file attribute view provides access to
legacy "DOS" attributes supported by the file systems such as File
Allocation Table (FAT), commonly used in consumer devices. It is
implementation specific if all file attributes are read as an atomic
operation with respect to other file system operations.
The options
array may be used to indicate how symbolic links
are handled for the case that the file is a symbolic link. By default,
symbolic links are followed and the file attributes of the final target
of the link are read. If the option NOFOLLOW_LINKS
is present then symbolic links are not followed and so
the method returns the file attributes of the symbolic link itself.
file
- A file reference that locates the fileoptions
- Options indicating how symbolic links are handledUnsupportedOperationException
- If the DosFileAttributeView
is not availableIOException
- If an I/O error occursSecurityException
- In the case of the default provider, the security manager's checkRead
method is invoked
to check read access to fileDosFileAttributeView.readAttributes()
public static UserPrincipal getOwner(FileRef file) throws IOException
The file
parameter locates a file that supports the FileOwnerAttributeView
. This file attribute view provides access to
a file attribute that is the owner of the file.
file
- A file reference that locates the fileUnsupportedOperationException
- If the FileOwnerAttributeView
is not availableIOException
- If an I/O error occursSecurityException
- In the case of the default provider, and a security manager is
installed, it denies RuntimePermission
("accessUserInformation")
or its checkRead
method
denies read access to the file.FileOwnerAttributeView.getOwner()
public static void setOwner(FileRef file, UserPrincipal owner) throws IOException
The file
parameter locates a file that supports the FileOwnerAttributeView
. This file attribute view provides access to
a file attribute that is the owner of the file.
file
- A file reference that locates the fileowner
- The new file ownerUnsupportedOperationException
- If the FileOwnerAttributeView
is not availableIOException
- If an I/O error occursSecurityException
- In the case of the default provider, and a security manager is
installed, it denies RuntimePermission
("accessUserInformation")
or its checkWrite
method denies write access to the file.FileOwnerAttributeView.setOwner(java.nio.file.attribute.UserPrincipal)
public static List<AclEntry> getAcl(FileRef file) throws IOException
The file
parameter locates a file that supports the AclFileAttributeView
. This file attribute view provides access to ACLs
based on the ACL model specified in
file
- A file reference that locates the fileentries
representing the
ACL. The returned list is modifiable.UnsupportedOperationException
- If the AclAttributeView
is not availableIOException
- If an I/O error occursSecurityException
- In the case of the default provider, and a security manager is
installed, it denies RuntimePermission
("accessUserInformation")
or its checkRead
method
denies read access to the file.AclFileAttributeView.getAcl()
public static void setAcl(FileRef file, List<AclEntry> acl) throws IOException
The file
parameter locates a file that supports the AclFileAttributeView
. This file attribute view provides access to ACLs
based on the ACL model specified in
file
- A file reference that locates the fileacl
- The new file ACLUnsupportedOperationException
- If the AclFileAttributeView
is not availableIOException
- If an I/O error occursSecurityException
- In the case of the default provider, and a security manager is
installed, it denies RuntimePermission
("accessUserInformation")
or its checkWrite
method denies write access to the file.AclFileAttributeView.setAcl(java.util.List)
public static void setLastModifiedTime(FileRef file, FileTime lastModifiedTime) throws IOException
IOException
.
If the file system does not support a last modified time attribute then this method has no effect.
Usage Example: Suppose we want to set the last modified time to the current time:
FileTime now = FileTime.fromMillis(System.currentTimeMillis()); Attributes.setLastModifiedTime(file, now);
file
- A file reference that locates the filelastModifiedTime
- The new last modified timeIOException
- If an I/O error occursSecurityException
- In the case of the default provider, the security manager's checkWrite
method is invoked
to check write access to fileBasicFileAttributeView.setTimes(java.nio.file.attribute.FileTime, java.nio.file.attribute.FileTime, java.nio.file.attribute.FileTime)
public static void setLastAccessTime(FileRef file, FileTime lastAccessTime) throws IOException
IOException
.
If the file system does not support a last access time attribute then this method has no effect.
file
- A file reference that locates the filelastAccessTime
- The new last access timeIOException
- If an I/O error occursSecurityException
- In the case of the default provider, the security manager's checkWrite
method is invoked
to check write access to fileBasicFileAttributeView.setTimes(java.nio.file.attribute.FileTime, java.nio.file.attribute.FileTime, java.nio.file.attribute.FileTime)
public static void setPosixFilePermissions(FileRef file, Set<PosixFilePermission> perms) throws IOException
The file
parameter is a reference to an existing file. It
supports the PosixFileAttributeView
that provides access to file
attributes commonly associated with files on file systems used by
operating systems that implement the Portable Operating System Interface
(POSIX) family of standards.
file
- A file reference that locates the fileperms
- The new set of permissionsUnsupportedOperationException
- If PosixFileAttributeView
is not availableClassCastException
- If the sets contains elements that are not of type PosixFilePermission
IOException
- If an I/O error occursSecurityException
- In the case of the default provider, and a security manager is
installed, it denies RuntimePermission
("accessUserInformation")
or its checkWrite
method denies write access to the file.PosixFileAttributeView.setPermissions(java.util.Set)
public static FileStoreSpaceAttributes readFileStoreSpaceAttributes(FileStore store) throws IOException
The store
parameter is a file store that supports the
FileStoreSpaceAttributeView
providing access to the space related
attributes of the file store. It is implementation specific if all attributes
are read as an atomic operation with respect to other file system operations.
store
- The file storeUnsupportedOperationException
- If the file store space attribute view is not supportedIOException
- If an I/O error occursFileStoreSpaceAttributeView.readAttributes()
|
Java™ Platform Standard Ed. 7 DRAFT ea-b118 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1993, 2010, Oracle Corporation. All rights reserved.