Path: blob/master/src/java.base/share/classes/java/nio/file/attribute/BasicFileAttributes.java
41161 views
/*1* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.nio.file.attribute;2627/**28* Basic attributes associated with a file in a file system.29*30* <p> Basic file attributes are attributes that are common to many file systems31* and consist of mandatory and optional file attributes as defined by this32* interface.33*34* <p> <b>Usage Example:</b>35* <pre>36* Path file = ...37* BasicFileAttributes attrs = Files.readAttributes(file, BasicFileAttributes.class);38* </pre>39*40* @since 1.741*42* @see BasicFileAttributeView43*/4445public interface BasicFileAttributes {4647/**48* Returns the time of last modification.49*50* <p> If the file system implementation does not support a time stamp51* to indicate the time of last modification then this method returns an52* implementation specific default value, typically a {@code FileTime}53* representing the epoch (1970-01-01T00:00:00Z).54*55* @return a {@code FileTime} representing the time the file was last56* modified57*/58FileTime lastModifiedTime();5960/**61* Returns the time of last access.62*63* <p> If the file system implementation does not support a time stamp64* to indicate the time of last access then this method returns65* an implementation specific default value, typically the {@link66* #lastModifiedTime() last-modified-time} or a {@code FileTime}67* representing the epoch (1970-01-01T00:00:00Z).68*69* @return a {@code FileTime} representing the time of last access70*/71FileTime lastAccessTime();7273/**74* Returns the creation time. The creation time is the time that the file75* was created.76*77* <p> If the file system implementation does not support a time stamp78* to indicate the time when the file was created then this method returns79* an implementation specific default value, typically the {@link80* #lastModifiedTime() last-modified-time} or a {@code FileTime}81* representing the epoch (1970-01-01T00:00:00Z).82*83* @return a {@code FileTime} representing the time the file was created84*/85FileTime creationTime();8687/**88* Tells whether the file is a regular file with opaque content.89*90* @return {@code true} if the file is a regular file with opaque content91*/92boolean isRegularFile();9394/**95* Tells whether the file is a directory.96*97* @return {@code true} if the file is a directory98*/99boolean isDirectory();100101/**102* Tells whether the file is a symbolic link.103*104* @return {@code true} if the file is a symbolic link105*/106boolean isSymbolicLink();107108/**109* Tells whether the file is something other than a regular file, directory,110* or symbolic link.111*112* @return {@code true} if the file something other than a regular file,113* directory or symbolic link114*/115boolean isOther();116117/**118* Returns the size of the file (in bytes). The size may differ from the119* actual size on the file system due to compression, support for sparse120* files, or other reasons. The size of files that are not {@link121* #isRegularFile regular} files is implementation specific and122* therefore unspecified.123*124* @return the file size, in bytes125*/126long size();127128/**129* Returns an object that uniquely identifies the given file, or {@code130* null} if a file key is not available. On some platforms or file systems131* it is possible to use an identifier, or a combination of identifiers to132* uniquely identify a file. Such identifiers are important for operations133* such as file tree traversal in file systems that support <a134* href="../package-summary.html#links">symbolic links</a> or file systems135* that allow a file to be an entry in more than one directory. On UNIX file136* systems, for example, the <em>device ID</em> and <em>inode</em> are137* commonly used for such purposes.138*139* <p> The file key returned by this method can only be guaranteed to be140* unique if the file system and files remain static. Whether a file system141* re-uses identifiers after a file is deleted is implementation dependent and142* therefore unspecified.143*144* <p> File keys returned by this method can be compared for equality and are145* suitable for use in collections. If the file system and files remain static,146* and two files are the {@link java.nio.file.Files#isSameFile same} with147* non-{@code null} file keys, then their file keys are equal.148*149* @return an object that uniquely identifies the given file, or {@code null}150*151* @see java.nio.file.Files#walkFileTree152*/153Object fileKey();154}155156157