Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/nio/file/package-info.java
38918 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*/2425/**26* Defines interfaces and classes for the Java virtual machine to access files,27* file attributes, and file systems.28*29* <p> The java.nio.file package defines classes to access files and file30* systems. The API to access file and file system attributes is defined in the31* {@link java.nio.file.attribute} package. The {@link java.nio.file.spi}32* package is used by service provider implementors wishing to extend the33* platform default provider, or to construct other provider implementations. </p>34*35* <h3><a name="links">Symbolic Links</a></h3>36* <p> Many operating systems and file systems support for <em>symbolic links</em>.37* A symbolic link is a special file that serves as a reference to another file.38* For the most part, symbolic links are transparent to applications and39* operations on symbolic links are automatically redirected to the <em>target</em>40* of the link. Exceptions to this are when a symbolic link is deleted or41* renamed/moved in which case the link is deleted or removed rather than the42* target of the link. This package includes support for symbolic links where43* implementations provide these semantics. File systems may support other types44* that are semantically close but support for these other types of links is45* not included in this package. </p>46*47* <h3><a name="interop">Interoperability</a></h3>48* <p> The {@link java.io.File} class defines the {@link java.io.File#toPath49* toPath} method to construct a {@link java.nio.file.Path} by converting50* the abstract path represented by the {@code java.io.File} object. The resulting51* {@code Path} can be used to operate on the same file as the {@code File}52* object. The {@code Path} specification provides further information53* on the <a href="Path.html#interop">interoperability</a> between {@code Path}54* and {@code java.io.File} objects. </p>55*56* <h3>Visibility</h3>57* <p> The view of the files and file system provided by classes in this package are58* guaranteed to be consistent with other views provided by other instances in the59* same Java virtual machine. The view may or may not, however, be consistent with60* the view of the file system as seen by other concurrently running programs due61* to caching performed by the underlying operating system and delays induced by62* network-filesystem protocols. This is true regardless of the language in which63* these other programs are written, and whether they are running on the same machine64* or on some other machine. The exact nature of any such inconsistencies are65* system-dependent and are therefore unspecified. </p>66*67* <h3><a name="integrity">Synchronized I/O File Integrity</a></h3>68* <p> The {@link java.nio.file.StandardOpenOption#SYNC SYNC} and {@link69* java.nio.file.StandardOpenOption#DSYNC DSYNC} options are used when opening a file70* to require that updates to the file are written synchronously to the underlying71* storage device. In the case of the default provider, and the file resides on72* a local storage device, and the {@link java.nio.channels.SeekableByteChannel73* seekable} channel is connected to a file that was opened with one of these74* options, then an invocation of the {@link75* java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer) write}76* method is only guaranteed to return when all changes made to the file77* by that invocation have been written to the device. These options are useful78* for ensuring that critical information is not lost in the event of a system79* crash. If the file does not reside on a local device then no such guarantee80* is made. Whether this guarantee is possible with other {@link81* java.nio.file.spi.FileSystemProvider provider} implementations is provider82* specific. </p>83*84* <h3>General Exceptions</h3>85* <p> Unless otherwise noted, passing a {@code null} argument to a constructor86* or method of any class or interface in this package will cause a {@link87* java.lang.NullPointerException NullPointerException} to be thrown. Additionally,88* invoking a method with a collection containing a {@code null} element will89* cause a {@code NullPointerException}, unless otherwise specified. </p>90*91* <p> Unless otherwise noted, methods that attempt to access the file system92* will throw {@link java.nio.file.ClosedFileSystemException} when invoked on93* objects associated with a {@link java.nio.file.FileSystem} that has been94* {@link java.nio.file.FileSystem#close closed}. Additionally, any methods95* that attempt write access to a file system will throw {@link96* java.nio.file.ReadOnlyFileSystemException} when invoked on an object associated97* with a {@link java.nio.file.FileSystem} that only provides read-only98* access. </p>99*100* <p> Unless otherwise noted, invoking a method of any class or interface in101* this package created by one {@link java.nio.file.spi.FileSystemProvider102* provider} with a parameter that is an object created by another provider,103* will throw {@link java.nio.file.ProviderMismatchException}. </p>104*105* <h3>Optional Specific Exceptions</h3>106* Most of the methods defined by classes in this package that access the107* file system specify that {@link java.io.IOException} be thrown when an I/O108* error occurs. In some cases, these methods define specific I/O exceptions109* for common cases. These exceptions, noted as <i>optional specific exceptions</i>,110* are thrown by the implementation where it can detect the specific error.111* Where the specific error cannot be detected then the more general {@code112* IOException} is thrown.113*114* @since 1.7115*/116package java.nio.file;117118119