Interface BasicFileAttributes
- All Known Subinterfaces:
-
DosFileAttributes
,PosixFileAttributes
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.
Usage Example:
Path file = ... BasicFileAttributes attrs = Files.readAttributes(file, BasicFileAttributes.class);
- Since:
- 1.7
- See Also:
Method Summary
Modifier and Type | Method | Description |
---|---|---|
FileTime |
creationTime() |
Returns the creation time. |
Object |
fileKey() |
Returns an object that uniquely identifies the given file, or
null if a file key is not available. |
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). |
Method Details
lastModifiedTime
FileTime 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).
- Returns:
- a
FileTime
representing the time the file was last modified
lastAccessTime
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).
- Returns:
- a
FileTime
representing the time of last access
creationTime
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).
- Returns:
- a
FileTime
representing the time the file was created
isRegularFile
boolean isRegularFile()
- Returns:
-
true
if the file is a regular file with opaque content
isDirectory
boolean isDirectory()
- Returns:
-
true
if the file is a directory
isSymbolicLink
boolean isSymbolicLink()
- Returns:
-
true
if the file is a symbolic link
isOther
boolean isOther()
- Returns:
-
true
if the file something other than a regular file, directory or symbolic link
size
long size()
regular
files is implementation specific and therefore unspecified.- Returns:
- the file size, in bytes
fileKey
Object fileKey()
null
if a file key is not available. On some platforms or file systems it is possible to use an identifier, or a combination of identifiers to uniquely identify a file. Such identifiers are important for operations such as file tree traversal in file systems that support symbolic links or file systems that allow a file to be an entry in more than one directory. On UNIX file systems, for example, the device ID and inode are commonly used for such purposes. The file key returned by this method can only be guaranteed to be unique if the file system and files remain static. Whether a file system re-uses identifiers after a file is deleted is implementation dependent and therefore unspecified.
File keys returned by this method can be compared for equality and are suitable for use in collections. If the file system and files remain static, and two files are the same
with non-null
file keys, then their file keys are equal.
- Returns:
- an object that uniquely identifies the given file, or
null
- See Also:
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/file/attribute/BasicFileAttributes.html