Posted by kalali
on May 20, 2010 at 2:25 AM PDT
I will write a series of blog introducing what are new features for handling I/O in Java 7. In the first part we are just going to check what do we have in Java 7 for dealing with I/O requirements which were not included in the previous versions of Java platform standard edition.
I will write a series of blog to discuss what are the new features introduced in NIO.2 (JSR 203). The NIO.2 implementation is a part of OpenJDK project and we can alreay use it by downloading a copy of OpenJDK binary . In the first entry I will just go through what are these new I/O features of Java 7, which help developer iron out better applications easier.
Talking about File systems support and features which let us deal with file system we can name the following features:
- Platform friendly-ness of NIO.2: We can deal with all file systems in a unified model.
- File tree walk: We can walk on a file tree and examine each node using the built-in APIs, NIO.2 to let us know whether the current member is a file, a directory or a symbolic link. We can then perform any operation we want on that node.
- File Operations (Copy, Delete, Move): Basic operations are supported with plethora of options. The move operation can be performed in atomic way.
- Symbolic links support: count soft and hard links as well as managing them.
- Support for file attributes in NIO.2: Managing file systems attributes is fully supported for different file systems including DOS, POSIX...
- File system change notification: We can setup a watch service and receive notification when a change happens on the path we are watching.
- SPI for providing new file systems support, for example to support zip, zfs, btrfs, we can implement the provider interfaces and use the unified API to access that specific file system using our implementation
Working with sockets and reding/ writing files we can name the following features:
- Multicasting is now supported in the DatagramChannel meaning that we can send and receive IP datagrams from a complete group. Both IPv4 and IPv6 are supported.
- Asynchronous I/O for sockets and Files: Now we can have Asynchronous read and write both on channles and files. It basically means we can have event driven I/O over both networks and files.
Other improvement, features:
- Support for very large multi gigabyte buffers
- Some MXBeans are included to monitor IO specific buffers.
- Interoperability between Java 7 IO and previous versions using the Path API.
I will post sample codes for each of these features in upcomming entries. So stay tuned if you want to learn more about NIO.2