接口 | 描述 |
---|---|
CopyOption |
配置如何复制或移动文件的对象。
|
DirectoryStream<T> |
一个对象来迭代目录中的条目。
|
DirectoryStream.Filter<T> |
由对象执行的接口,用于确定是否应接受或过滤目录条目。
|
FileVisitor<T> |
文件访问者
|
OpenOption |
配置如何打开或创建文件的对象。
|
Path |
可用于在文件系统中定位文件的对象。
|
PathMatcher |
由对路径执行匹配操作的对象实现的接口。
|
SecureDirectoryStream<T> |
A
DirectoryStream ,它定义了相对于打开目录定位的文件的操作。
|
Watchable |
可以注册到手表服务的对象,以便可以
观看更改和事件。
|
WatchEvent<T> |
一个事件或一个重复的事件,一个对象注册了一个 WatchService 。
|
WatchEvent.Kind<T> |
一种事件类型,用于识别。
|
WatchEvent.Modifier |
事件修饰符,用于量化如何 Watchable 与注册WatchService 。
|
WatchKey |
表示的登记令牌 watchable 对象与WatchService 。
|
WatchService |
监视注册对象进行更改和事件的监视服务。
|
类 | 描述 |
---|---|
Files |
该类只包含对文件,目录或其他类型文件进行操作的静态方法。
|
FileStore |
文件存储
|
FileSystem |
提供文件系统的接口,并且是工厂用于访问文件系统中的文件和其他对象的对象。
|
FileSystems |
文件系统的工厂方法。
|
LinkPermission |
用于链接创建操作的
Permission 类。
|
Paths | |
SimpleFileVisitor<T> |
具有默认行为的简单文件访问者访问所有文件并重新抛出I / O错误。
|
StandardWatchEventKinds |
定义
标准事件种类。
|
Enum | 描述 |
---|---|
AccessMode |
定义用于测试文件可访问性的访问模式。
|
FileVisitOption |
定义文件树遍历选项。
|
FileVisitResult |
结果类型为 FileVisitor 。
|
LinkOption |
定义如何处理符号链接的选项。
|
StandardCopyOption |
定义标准复制选项。
|
StandardOpenOption |
定义标准的开放选项。
|
异常 | 描述 |
---|---|
AccessDeniedException |
文件系统操作被拒绝时引发的检查异常,通常是由于文件权限或其他访问检查。
|
AtomicMoveNotSupportedException |
当文件不能作为原子文件系统操作移动时,检查的异常抛出。
|
ClosedDirectoryStreamException |
尝试在关闭的目录流上调用操作时抛出未检查的异常。
|
ClosedFileSystemException |
尝试在文件上调用操作并关闭文件系统时抛出未检查的异常。
|
ClosedWatchServiceException |
尝试在关闭的手表服务上调用操作时抛出未检查的异常。
|
DirectoryIteratorException |
如果在遍历目录中的条目时遇到I / O错误,则抛出运行时异常。
|
DirectoryNotEmptyException |
由于目录不为空,文件系统操作失败时抛出的检查异常。
|
FileAlreadyExistsException |
尝试创建文件或目录并且该名称的文件已存在时,检查的异常抛出。
|
FileSystemAlreadyExistsException |
尝试创建已存在的文件系统时抛出运行时异常。
|
FileSystemException |
在一个或两个文件上的文件系统操作失败时抛出。
|
FileSystemLoopException |
当遇到文件系统循环或循环时抛出的检查异常。
|
FileSystemNotFoundException |
无法找到文件系统时抛出的运行时异常。
|
InvalidPathException |
当路径字符串不能转换为 Path 因为路径字符串包含无效字符或路径字符串对于其他文件系统特定的原因无效时,将抛出未检查的异常。
|
NoSuchFileException |
当尝试访问不存在的文件时抛出检查的异常。
|
NotDirectoryException |
当文件系统操作用于目录时,由于文件不是目录而导致失败的检查异常。
|
NotLinkException |
由于文件不是符号链接,文件系统操作失败时抛出的检查异常。
|
ProviderMismatchException |
当尝试使用由不同文件系统提供程序创建的参数在一个文件系统提供程序创建的对象上调用方法时抛出未检查的异常。
|
ProviderNotFoundException |
无法找到所需类型的提供者时抛出的运行时异常。
|
ReadOnlyFileSystemException |
尝试更新与
read-only
FileSystem 的对象时抛出未检查的异常。
|
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 java.nio.file.spi
package is used by service provider implementors wishing to extend the platform default provider, or to construct other provider implementations.
Many operating systems and file systems support for symbolic links. A symbolic link is a special file that serves as a reference to another file. For the most part, symbolic links are transparent to applications and operations on symbolic links are automatically redirected to the target of the link. Exceptions to this are when a symbolic link is deleted or renamed/moved in which case the link is deleted or removed rather than the target of the link. This package includes support for symbolic links where implementations provide these semantics. File systems may support other types that are semantically close but support for these other types of links is not included in this package.
The File
class defines the toPath
method to construct a Path
by converting the abstract path represented by the java.io.File
object. The resulting Path
can be used to operate on the same file as the File
object. The Path
specification provides further information on the interoperability between Path
and java.io.File
objects.
The view of the files and file system provided by classes in this package are guaranteed to be consistent with other views provided by other instances in the same Java virtual machine. The view may or may not, however, be consistent with the view of the file system as seen by other concurrently running programs due to caching performed by the underlying operating system and delays induced by network-filesystem protocols. This is true regardless of the language in which these other programs are written, and whether they are running on the same machine or on some other machine. The exact nature of any such inconsistencies are system-dependent and are therefore unspecified.
The SYNC
and DSYNC
options 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 seekable
channel is connected to a file that was opened with one of these options, then an invocation of the write
method 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 provider
implementations is provider specific.
Unless otherwise noted, passing a null
argument to a constructor or method of any class or interface in this package will cause a NullPointerException
to be thrown. Additionally, invoking a method with a collection containing a null
element will cause a NullPointerException
, unless otherwise specified.
Unless otherwise noted, methods that attempt to access the file system will throw 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 with a FileSystem
that only provides read-only access.
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, will throw ProviderMismatchException
.
IOException
be 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
IOException
is thrown.