An object that configures how to copy or move a file.
An object to iterate over the entries in a directory.
An interface that is implemented by objects that decide if a directory entry should be accepted or filtered.
A visitor of files.
An object that configures how to open or create a file.
An object that may be used to locate a file in a file system.
An interface that is implemented by objects that perform match operations on paths.
An object that may be registered with a watch service so that it can be watched for changes and events.
An event or a repeated event for an object that is registered with a
An event kind, for the purposes of identification.
A watch service that watches registered objects for changes and events.
This class consists exclusively of static methods that operate on files, directories, or other types of files.
Storage for files.
Provides an interface to a file system and is the factory for objects to access files and other objects in the file system.
Factory methods for file systems.
A simple visitor of files with default behavior to visit all files and to re-throw I/O errors.
Defines the standard event kinds.
Defines access modes used to test the accessibility of a file.
Defines the file tree traversal options.
The result type of a
Defines the options as to how symbolic links are handled.
Defines the standard copy options.
Defines the standard open options.
Checked exception thrown when a file system operation is denied, typically due to a file permission or other access check.
Checked exception thrown when a file cannot be moved as an atomic file system operation.
Unchecked exception thrown when an attempt is made to invoke an operation on a directory stream that is closed.
Unchecked exception thrown when an attempt is made to invoke an operation on a file and the file system is closed.
Unchecked exception thrown when an attempt is made to invoke an operation on a watch service that is closed.
Runtime exception thrown if an I/O error is encountered when iterating over the entries in a directory.
Checked exception thrown when a file system operation fails because a directory is not empty.
Checked exception thrown when an attempt is made to create a file or directory and a file of that name already exists.
Runtime exception thrown when an attempt is made to create a file system that already exists.
Thrown when a file system operation fails on one or two files.
Checked exception thrown when a file system loop, or cycle, is encountered.
Runtime exception thrown when a file system cannot be found.
Unchecked exception thrown when path string cannot be converted into a
Checked exception thrown when an attempt is made to access a file that does not exist.
Checked exception thrown when a file system operation, intended for a directory, fails because the file is not a directory.
Checked exception thrown when a file system operation fails because a file is not a symbolic link.
Unchecked exception thrown when an attempt is made to invoke a method on an object created by one file system provider with a parameter created by a different file system provider.
Runtime exception thrown when a provider of the required type cannot be found.
Unchecked exception thrown when an attempt is made to update an object associated with a
The java.nio.file package defines classes to access files and file
systems. The API to access file and file system attributes is defined in the
java.nio.file.attribute package. The
package is used by service provider implementors wishing to extend the
platform default provider, or to construct other provider implementations.
Fileclass defines the
toPathmethod to construct a
Pathby converting the abstract path represented by the
java.io.Fileobject. The resulting
Pathcan be used to operate on the same file as the
Pathspecification provides further information on the interoperability between
DSYNCoptions are used when opening a file to require that updates to the file are written synchronously to the underlying storage device. In the case of the default provider, and the file resides on a local storage device, and the
seekablechannel is connected to a file that was opened with one of these options, then an invocation of the
writemethod is only guaranteed to return when all changes made to the file by that invocation have been written to the device. These options are useful for ensuring that critical information is not lost in the event of a system crash. If the file does not reside on a local device then no such guarantee is made. Whether this guarantee is possible with other
providerimplementations is provider specific.
nullargument to a constructor or method of any class or interface in this package will cause a
NullPointerExceptionto be thrown. Additionally, invoking a method with a collection containing a
nullelement will cause a
NullPointerException, unless otherwise specified.
Unless otherwise noted, methods that attempt to access the file system
ClosedFileSystemException when invoked on
objects associated with a
FileSystem that has been
closed. Additionally, any methods
that attempt write access to a file system will throw
ReadOnlyFileSystemException when invoked on an object associated
FileSystem that only provides read-only
Unless otherwise noted, invoking a method of any class or interface in
this package created by one
provider with a parameter that is an object created by another provider,
IOExceptionbe thrown when an I/O error occurs. In some cases, these methods define specific I/O exceptions for common cases. These exceptions, noted as optional specific exceptions, are thrown by the implementation where it can detect the specific error. Where the specific error cannot be detected then the more general
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, 2015, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.