public interface BasicFileAttributes
Basic file attributes are attributes that are common to many file systems and consist of mandatory and optional file attributes as defined by this interface.
The file attributes are retrieved from the file system as a bulk
operation by invoking the readAttributes
method.
Where dynamic access to file attributes is required, the attributes supported by this attribute view have the following names and types:
Name Type "lastModifiedTime" FileTime
"lastAccessTime" FileTime
"creationTime" FileTime
"size" Long
"isRegularFile" Boolean
"isDirectory" Boolean
"isSymbolicLink" Boolean
"isOther" Boolean
The getAttribute
method may be
used to read any of these attributes.
The setAttribute
method may be
used to update the file's last modified time, last access time or create time
attributes.
Usage Example:
Path file = ... BasicFileAttributes attrs = Files.readAttributes(file, BasicFileAttributes.class);
Modifier and Type | Method and Description |
---|---|
FileTime |
creationTime()
Returns the creation time.
|
boolean |
isDirectory()
Tells whether the file is a directory.
|
boolean |
isOther()
Tells whether the file is something other than a regular file, directory,
or symbolic link.
|
boolean |
isRegularFile()
Tells whether the file is a regular file with opaque content.
|
boolean |
isSymbolicLink()
Tells whether the file is a symbolic link.
|
FileTime |
lastAccessTime()
Returns the time of last access.
|
FileTime |
lastModifiedTime()
Returns the time of last modification.
|
long |
size()
Returns the size of the file (in bytes).
|
FileTime creationTime()
If the file system implementation does not support a time stamp
to indicate the time when the file was created then this method returns
an implementation specific default value, typically the last-modified-time
or a FileTime
representing the epoch (1970-01-01T00:00:00Z).
FileTime
representing the time the file was createdboolean isDirectory()
true
if the file is a directory, else false
boolean isOther()
true
if the not a regular file, directory or symbolic
link, else false
boolean isRegularFile()
true
if the file is a regular file, else false
boolean isSymbolicLink()
true
if the file is a symbolic link, else false
FileTime lastAccessTime()
If the file system implementation does not support a time stamp
to indicate the time of last access then this method returns
an implementation specific default value, typically the last-modified-time
or a FileTime
representing the epoch (1970-01-01T00:00:00Z).
FileTime
representing the time of last accessFileTime lastModifiedTime()
If the file system implementation does not support a time stamp
to indicate the time of last modification then this method returns an
implementation specific default value, typically a FileTime
representing the epoch (1970-01-01T00:00:00Z).
FileTime
representing the time the file was last
modifiedlong size()
regular
files is implementation specific and
therefore unspecified.Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. Use of this specification is subject to license terms.