Spec-Zone .ru
спецификации, руководства, описания, API
Please note that the specifications and other information contained herein are not final and are subject to change. The information is being made available to you solely for purpose of evaluation.

Java™ Platform
Standard Ed. 7

DRAFT ea-b118

java.nio.file.attribute
Interface BasicFileAttributes

All Known Subinterfaces:
DosFileAttributes, PosixFileAttributes

public interface BasicFileAttributes

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:

    FileRef file = ...
    BasicFileAttributes attrs = Attributes.readBasicFileAttributes(file);
 

Since:
1.7
See Also:
BasicFileAttributeView

Method Summary
Modifier and Type Method and Description
 FileTime creationTime()
          Returns the creation time if supported.
 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 if supported.
 FileTime lastModifiedTime()
          Returns the time of last modification.
 long size()
          Returns the size of the file (in bytes).
 

Method Detail

lastModifiedTime

FileTime lastModifiedTime()
Returns the time of last modification.

Returns:
a FileTime representing the time the file was last modified or null if the attribute is not supported.

lastAccessTime

FileTime lastAccessTime()
Returns the time of last access if supported.

Returns:
a FileTime representing the time of last access or null if the attribute is not supported.

creationTime

FileTime creationTime()
Returns the creation time if supported. The creation time is the time that the file was created.

Returns:
a FileTime representing the time the file was created or null if the attribute is not supported.

isRegularFile

boolean isRegularFile()
Tells whether the file is a regular file with opaque content.


isDirectory

boolean isDirectory()
Tells whether the file is a directory.


isSymbolicLink

boolean isSymbolicLink()
Tells whether the file is a symbolic link.


isOther

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


size

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:
the file size, in bytes

fileKey

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.

See Also:
Files.walkFileTree(java.nio.file.Path, java.util.Set, int, java.nio.file.FileVisitor<? super java.nio.file.Path>)

Java™ Platform
Standard Ed. 7

DRAFT ea-b118

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright © 1993, 2010, Oracle Corporation. All rights reserved.
DRAFT ea-b118

Scripting on this page tracks web page traffic, but does not change the content in any way.