14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 /** 27 * Defines interfaces and classes for the Java virtual machine to access files, 28 * file attributes, and file systems. 29 * 30 * <p> The java.nio.file package defines classes to access files and file 31 * systems. The API to access file and file system attributes is defined in the 32 * {@link java.nio.file.attribute} package. The {@link java.nio.file.spi} 33 * package is used by service provider implementors wishing to extend the 34 * platform default provider, or to construct other provider implementations. 35 * 36 * <a name="links"><h3>Symbolic Links</h3></a> 37 * Many operating systems and file systems support for <em>symbolic links</em>. 38 * A symbolic link is a special file that serves as a reference to another file. 39 * For the most part, symbolic links are transparent to applications and 40 * operations on symbolic links are automatically redirected to the <em>target</em> 41 * of the link. Exceptions to this are when a symbolic link is deleted or 42 * renamed/moved in which case the link is deleted or removed rather than the 43 * target of the link. This package includes support for symbolic links where 44 * implementations provide these semantics. File systems may support other types 45 * that are semantically close but support for these other types of links is 46 * not included in this package. 47 * 48 * <a name="interop"><h3>Interoperability</h3></a> 49 * The {@link java.io.File} class defines the {@link java.io.File#toPath 50 * toPath} method to construct a {@link java.nio.file.Path} by converting 51 * the abstract path represented by the {@code java.io.File} object. The resulting 52 * {@code Path} can be used to operate on the same file as the {@code File} 53 * object. The {@code Path} specification provides further information 54 * on the <a href="Path.html#interop">interoperability</a> between {@code Path} 55 * and {@code java.io.File} objects. 56 * 57 * <h3>Visibility</h3> 58 * The view of the files and file system provided by classes in this package are 59 * guaranteed to be consistent with other views provided by other instances in the 60 * same Java virtual machine. The view may or may not, however, be consistent with 61 * the view of the file system as seen by other concurrently running programs due 62 * to caching performed by the underlying operating system and delays induced by 63 * network-filesystem protocols. This is true regardless of the language in which 64 * these other programs are written, and whether they are running on the same machine 65 * or on some other machine. The exact nature of any such inconsistencies are 66 * system-dependent and are therefore unspecified. 67 * 68 * <a name="integrity"><h3>Synchronized I/O File Integrity</h3></a> 69 * The {@link java.nio.file.StandardOpenOption#SYNC SYNC} and {@link 70 * java.nio.file.StandardOpenOption#DSYNC DSYNC} options are used when opening a file 71 * to require that updates to the file are written synchronously to the underlying 72 * storage device. In the case of the default provider, and the file resides on 73 * a local storage device, and the {@link java.nio.channels.SeekableByteChannel 74 * seekable} channel is connected to a file that was opened with one of these 75 * options, then an invocation of the {@link 76 * java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer) write} 77 * method is only guaranteed to return when all changes made to the file 78 * by that invocation have been written to the device. These options are useful 79 * for ensuring that critical information is not lost in the event of a system 80 * crash. If the file does not reside on a local device then no such guarantee 81 * is made. Whether this guarantee is possible with other {@link 82 * java.nio.file.spi.FileSystemProvider provider} implementations is provider 83 * specific. 84 * 85 * <h3>General Exceptions</h3> 86 * Unless otherwise noted, passing a {@code null} argument to a constructor 87 * or method of any class or interface in this package will cause a {@link 88 * java.lang.NullPointerException NullPointerException} to be thrown. Additionally, 89 * invoking a method with a collection containing a {@code null} element will 90 * cause a {@code NullPointerException}, unless otherwise specified. 91 * 92 * <p> Unless otherwise noted, methods that attempt to access the file system 93 * will throw {@link java.nio.file.ClosedFileSystemException} when invoked on 94 * objects associated with a {@link java.nio.file.FileSystem} that has been 95 * {@link java.nio.file.FileSystem#close closed}. Additionally, any methods 96 * that attempt write access to a file system will throw {@link 97 * java.nio.file.ReadOnlyFileSystemException} when invoked on an object associated 98 * with a {@link java.nio.file.FileSystem} that only provides read-only access. 99 * 100 * <p> Unless otherwise noted, invoking a method of any class or interface in 101 * this package created by one {@link java.nio.file.spi.FileSystemProvider 102 * provider} with a parameter that is an object created by another provider, 103 * will throw {@link java.nio.file.ProviderMismatchException}. 104 * 105 * <h3>Optional Specific Exceptions</h3> 106 * Most of the methods defined by classes in this package that access the 107 * file system specify that {@link java.io.IOException} be thrown when an I/O 108 * error occurs. In some cases, these methods define specific I/O exceptions 109 * 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 {@code 112 * IOException} is thrown. 113 * 114 * @since 1.7 115 */ 116 package java.nio.file; | 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 /** 27 * Defines interfaces and classes for the Java virtual machine to access files, 28 * file attributes, and file systems. 29 * 30 * <p> The java.nio.file package defines classes to access files and file 31 * systems. The API to access file and file system attributes is defined in the 32 * {@link java.nio.file.attribute} package. The {@link java.nio.file.spi} 33 * package is used by service provider implementors wishing to extend the 34 * platform default provider, or to construct other provider implementations. </p> 35 * 36 * <a name="links"><h3>Symbolic Links</h3></a> 37 * Many operating systems and file systems support for <em>symbolic links</em>. 38 * A symbolic link is a special file that serves as a reference to another file. 39 * For the most part, symbolic links are transparent to applications and 40 * operations on symbolic links are automatically redirected to the <em>target</em> 41 * of the link. Exceptions to this are when a symbolic link is deleted or 42 * renamed/moved in which case the link is deleted or removed rather than the 43 * target of the link. This package includes support for symbolic links where 44 * implementations provide these semantics. File systems may support other types 45 * that are semantically close but support for these other types of links is 46 * not included in this package. </p> 47 * 48 * <a name="interop"><h3>Interoperability</h3></a> 49 * The {@link java.io.File} class defines the {@link java.io.File#toPath 50 * toPath} method to construct a {@link java.nio.file.Path} by converting 51 * the abstract path represented by the {@code java.io.File} object. The resulting 52 * {@code Path} can be used to operate on the same file as the {@code File} 53 * object. The {@code Path} specification provides further information 54 * on the <a href="Path.html#interop">interoperability</a> between {@code Path} 55 * and {@code java.io.File} objects. </p> 56 * 57 * <h3>Visibility</h3> 58 * The view of the files and file system provided by classes in this package are 59 * guaranteed to be consistent with other views provided by other instances in the 60 * same Java virtual machine. The view may or may not, however, be consistent with 61 * the view of the file system as seen by other concurrently running programs due 62 * to caching performed by the underlying operating system and delays induced by 63 * network-filesystem protocols. This is true regardless of the language in which 64 * these other programs are written, and whether they are running on the same machine 65 * or on some other machine. The exact nature of any such inconsistencies are 66 * system-dependent and are therefore unspecified. </p> 67 * 68 * <a name="integrity"><h3>Synchronized I/O File Integrity</h3></a> 69 * The {@link java.nio.file.StandardOpenOption#SYNC SYNC} and {@link 70 * java.nio.file.StandardOpenOption#DSYNC DSYNC} options are used when opening a file 71 * to require that updates to the file are written synchronously to the underlying 72 * storage device. In the case of the default provider, and the file resides on 73 * a local storage device, and the {@link java.nio.channels.SeekableByteChannel 74 * seekable} channel is connected to a file that was opened with one of these 75 * options, then an invocation of the {@link 76 * java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer) write} 77 * method is only guaranteed to return when all changes made to the file 78 * by that invocation have been written to the device. These options are useful 79 * for ensuring that critical information is not lost in the event of a system 80 * crash. If the file does not reside on a local device then no such guarantee 81 * is made. Whether this guarantee is possible with other {@link 82 * java.nio.file.spi.FileSystemProvider provider} implementations is provider 83 * specific. </p> 84 * 85 * <h3>General Exceptions</h3> 86 * Unless otherwise noted, passing a {@code null} argument to a constructor 87 * or method of any class or interface in this package will cause a {@link 88 * java.lang.NullPointerException NullPointerException} to be thrown. Additionally, 89 * invoking a method with a collection containing a {@code null} element will 90 * cause a {@code NullPointerException}, unless otherwise specified. </p> 91 * 92 * <p> Unless otherwise noted, methods that attempt to access the file system 93 * will throw {@link java.nio.file.ClosedFileSystemException} when invoked on 94 * objects associated with a {@link java.nio.file.FileSystem} that has been 95 * {@link java.nio.file.FileSystem#close closed}. Additionally, any methods 96 * that attempt write access to a file system will throw {@link 97 * java.nio.file.ReadOnlyFileSystemException} when invoked on an object associated 98 * with a {@link java.nio.file.FileSystem} that only provides read-only 99 * access. </p> 100 * 101 * <p> Unless otherwise noted, invoking a method of any class or interface in 102 * this package created by one {@link java.nio.file.spi.FileSystemProvider 103 * provider} with a parameter that is an object created by another provider, 104 * will throw {@link java.nio.file.ProviderMismatchException}. </p> 105 * 106 * <h3>Optional Specific Exceptions</h3> 107 * Most of the methods defined by classes in this package that access the 108 * file system specify that {@link java.io.IOException} be thrown when an I/O 109 * error occurs. In some cases, these methods define specific I/O exceptions 110 * for common cases. These exceptions, noted as <i>optional specific exceptions</i>, 111 * are thrown by the implementation where it can detect the specific error. 112 * Where the specific error cannot be detected then the more general {@code 113 * IOException} is thrown. 114 * 115 * @since 1.7 116 */ 117 package java.nio.file; |