BasicFileAttributes.java revision 1381
893N/A/*
893N/A * Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved.
893N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
893N/A *
893N/A * This code is free software; you can redistribute it and/or modify it
893N/A * under the terms of the GNU General Public License version 2 only, as
893N/A * published by the Free Software Foundation. Sun designates this
893N/A * particular file as subject to the "Classpath" exception as provided
893N/A * by Sun in the LICENSE file that accompanied this code.
893N/A *
893N/A * This code is distributed in the hope that it will be useful, but WITHOUT
893N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
893N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
893N/A * version 2 for more details (a copy is included in the LICENSE file that
893N/A * accompanied this code).
893N/A *
893N/A * You should have received a copy of the GNU General Public License version
893N/A * 2 along with this work; if not, write to the Free Software Foundation,
893N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
893N/A *
893N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
893N/A * CA 95054 USA or visit www.sun.com if you need additional information or
893N/A * have any questions.
893N/A */
893N/A
893N/Apackage java.nio.file.attribute;
893N/A
893N/A/**
893N/A * Basic attributes associated with a file in a file system.
893N/A *
893N/A * <p> Basic file attributes are attributes that are common to many file systems
893N/A * and consist of mandatory and optional file attributes as defined by this
893N/A * interface.
893N/A *
893N/A * <p> <b>Usage Example:</b>
893N/A * <pre>
893N/A * FileRef file = ...
893N/A * BasicFileAttributes attrs = Attributes.readBasicFileAttributes(file);
893N/A * </pre>
893N/A *
893N/A * @since 1.7
893N/A *
893N/A * @see BasicFileAttributeView
893N/A */
893N/A
893N/Apublic interface BasicFileAttributes {
893N/A
893N/A /**
893N/A * Returns the time of last modification.
893N/A *
1319N/A * @return a {@code FileTime} representing the time the file was last
1319N/A * modified or {@code null} if the attribute is not supported.
893N/A */
1319N/A FileTime lastModifiedTime();
893N/A
893N/A /**
893N/A * Returns the time of last access if supported.
893N/A *
1319N/A * @return a {@code FileTime} representing the time of last access or
1319N/A * {@code null} if the attribute is not supported.
893N/A */
1319N/A FileTime lastAccessTime();
893N/A
893N/A /**
893N/A * Returns the creation time if supported. The creation time is the time
893N/A * that the file was created.
893N/A *
1319N/A * @return a {@code FileTime} representing the time the file was created
1319N/A * or {@code null} if the attribute is not supported.
893N/A */
1319N/A FileTime creationTime();
893N/A
893N/A /**
893N/A * Tells whether the file is a regular file with opaque content.
893N/A */
893N/A boolean isRegularFile();
893N/A
893N/A /**
893N/A * Tells whether the file is a directory.
893N/A */
893N/A boolean isDirectory();
893N/A
893N/A /**
1381N/A * Tells whether the file is a symbolic link.
893N/A */
893N/A boolean isSymbolicLink();
893N/A
893N/A /**
893N/A * Tells whether the file is something other than a regular file, directory,
1381N/A * or symbolic link.
893N/A */
893N/A boolean isOther();
893N/A
893N/A /**
893N/A * Returns the size of the file (in bytes). The size may differ from the
893N/A * actual size on the file system due to compression, support for sparse
893N/A * files, or other reasons. The size of files that are not {@link
893N/A * #isRegularFile regular} files is implementation specific and
893N/A * therefore unspecified.
893N/A *
908N/A * @return the file size, in bytes
893N/A */
893N/A long size();
893N/A
893N/A /**
893N/A * Returns an object that uniquely identifies the given file, or {@code
893N/A * null} if a file key is not available. On some platforms or file systems
893N/A * it is possible to use an identifier, or a combination of identifiers to
893N/A * uniquely identify a file. Such identifiers are important for operations
893N/A * such as file tree traversal in file systems that support <a
893N/A * href="../package-summary.html#links">symbolic links</a> or file systems
893N/A * that allow a file to be an entry in more than one directory. On UNIX file
893N/A * systems, for example, the <em>device ID</em> and <em>inode</em> are
893N/A * commonly used for such purposes.
893N/A *
893N/A * <p> The file key returned by this method can only be guaranteed to be
893N/A * unique if the file system and files remain static. Whether a file system
893N/A * re-uses identifiers after a file is deleted is implementation dependent and
893N/A * therefore unspecified.
893N/A *
893N/A * <p> File keys returned by this method can be compared for equality and are
893N/A * suitable for use in collections. If the file system and files remain static,
1319N/A * and two files are the {@link java.nio.file.Path#isSameFile same} with
893N/A * non-{@code null} file keys, then their file keys are equal.
893N/A *
893N/A * @see java.nio.file.Files#walkFileTree
893N/A */
893N/A Object fileKey();
893N/A}