Masoud Kalali has a software engineering degree and has been working on software development projects since 1998. He has experience with a variety of technologies (.NET, J2EE, CORBA, and COM+) on diverse platforms (Solaris, Linux, and Windows). His experience is in software architecture, design, and server-side development. Masoud has published several articles at Java.net and Dzone. He has authored multiple refcards, published by Dzone, including but not limited to Using XML in Java, Java EE Security and GlassFish v3 refcardz. He is one of the founder members of NetBeans Dream Team and a GlassFish community spotlighted developer. Recently Masoud's new book, GlassFish Security has been published which covers GlassFish v3 security and Java EE 6 security. Masoud's main area of research and interest includes service-oriented architecture and large scale systems' development and deployment and in his leisure time he enjoys photography, mountaineering and camping. Masoud's can be followed at his Twitter account. Masoud has posted 82 posts at DZone. You can read more from them at their website. View Full User Profile

Introducing NIO.2 (JSR 203) Part 1: What Are The New Features?

05.21.2010
| 8250 views |
  • submit to reddit

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:

  1. Platform friendly-ness of NIO.2: We can deal with all file systems in a unified model.
  2. 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.
  3. File Operations (Copy, Delete, Move): Basic operations are supported with plethora of options. The move operation can be performed in atomic way.
  4. Symbolic links support: count soft and hard links as well as managing them.
  5. Support for file attributes in NIO.2: Managing file systems attributes is fully supported for different file systems including DOS, POSIX...
  6. File system change notification: We can setup a watch service and receive notification when a change happens on the path we are watching.
  7. 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:

  1. 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.
  2. 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:

  1. Support for very large multi gigabyte buffers
  2. Some MXBeans are included to monitor IO specific buffers.
  3. 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

 

From http://weblogs.java.net/blog/kalali/archive/2010/05/19/introducing-nio2-jsr-203-part-1-what-are-new-features

Published at DZone with permission of its author, Masoud Kalali.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags:

Comments

Franklin Ike replied on Fri, 2010/05/21 - 6:47am

Was looking at NIO2 changes a couple of weeks ago and I was really blown away with the File System changes. A very very welcome addition in Java 7.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.