Java Reference
In-Depth Information
Chapter 10
New Input/Output 2
In this chapter, you will learn
What New Input/Output 2 is
How to work with a file system and file store
Path
How to represent a platform-dependent abstract pathname using a
Path object
How to perform different file operations on a
How to traverse a file tree
How to manage file attributes
How to watch a directory for changes
How to perform asynchronous file I/O operations
What Is New Input/Output 2?
Java 7 introduced New Input/Output 2 (NIO.2) API, which provides a new I/O API. It provides many features
that were lacking in the original File I/O API. The features provided in NIO.2 are essential for working with a file
system efficiently. It adds three packages to the Java class library: java.nio.file , java.nio.file.attribute , and
java.nio.file.spi . The following are some of the new features of NIO.2:
It lets you deal with all file systems in a uniform way. The file system support provided by
NIO.2 is extensible. You can use the default implementation for a file system or you can
choose to implement your own file system.
It supports basic file operations (copy, move, and delete) on all file systems. It supports an
atomic file move operation. It has improved exception handling support.
It has support for symbolic links. Whenever applicable, operations on a symbolic link are
redirected to the target file.
One of the most important additions to NIO.2 is the support for accessing the attributes of file
systems and files.
It lets you create a watch service to watch for any events on a directory such as adding a new
file or a subdirectory, deleting a file, etc. When such an event occurs on the directory, your
program receives a notification through the watch service.
 
Search WWH ::




Custom Search