APIdia Launch Partner
Top Description Methods
java.nio.file.attribute

public Interface BasicFileAttributes

Known Direct Subinterfaces
java.nio.file.attribute.DosFileAttributes, java.nio.file.attribute.PosixFileAttributes
Known Direct Implementers
sun.nio.fs.UnixFileAttributes.UnixAsBasicFileAttributes, jdk.internal.jrtfs.JrtFileAttributes

Basic attributes associated with a file in a file system.

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);
Path file = ...
BasicFileAttributes attrs = Files.readAttributes(file, BasicFileAttributes.class);
Since
1.7
See Also
BasicFileAttributeView

Method Summary

Modifier and TypeMethod and Description
public FileTime

Returns:

a FileTime representing the time the file was created
creationTime
()

Returns the creation time.

public Object

Returns:

an object that uniquely identifies the given file, or null
fileKey
()

Returns an object that uniquely identifies the given file, or null if a file key is not available.

public boolean

Returns:

true if the file is a directory
isDirectory
()

Tells whether the file is a directory.

public boolean

Returns:

true if the file something other than a regular file, directory or symbolic link
isOther
()

Tells whether the file is something other than a regular file, directory, or symbolic link.

public boolean

Returns:

true if the file is a regular file with opaque content
isRegularFile
()

Tells whether the file is a regular file with opaque content.

public FileTime

Returns:

a FileTime representing the time of last access
lastAccessTime
()

Returns the time of last access.

public FileTime

Returns:

a FileTime representing the time the file was last modified
lastModifiedTime
()

Returns the time of last modification.

public long

Returns:

the file size, in bytes
size
()

Returns the size of the file (in bytes).

Method Detail

creationTimeback to summary
public FileTime creationTime()

Returns the creation time. The creation time is the time that the file was created.

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:FileTime

a FileTime representing the time the file was created

fileKeyback to summary
public Object fileKey()

Returns an object that uniquely identifies the given file, or 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:Object

an object that uniquely identifies the given file, or null

See Also
java.nio.file.Files#walkFileTree
isDirectoryback to summary
public boolean isDirectory()

Tells whether the file is a directory.

Returns:boolean

true if the file is a directory

isOtherback to summary
public boolean isOther()

Tells whether the file is something other than a regular file, directory, or symbolic link.

Returns:boolean

true if the file something other than a regular file, directory or symbolic link

isRegularFileback to summary
public boolean isRegularFile()

Tells whether the file is a regular file with opaque content.

Returns:boolean

true if the file is a regular file with opaque content

lastAccessTimeback to summary
public FileTime lastAccessTime()

Returns the time of last access.

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:FileTime

a FileTime representing the time of last access

lastModifiedTimeback to summary
public FileTime lastModifiedTime()

Returns the time of last modification.

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:FileTime

a FileTime representing the time the file was last modified

sizeback to summary
public long size()

Returns the size of the file (in bytes). The size may differ from the actual size on the file system due to compression, support for sparse files, or other reasons. The size of files that are not regular files is implementation specific and therefore unspecified.

Returns:long

the file size, in bytes