by Ron Hitchens
System analyst and software engineer
14 August 2003
The Java New I/O (NIO) packages
introduced in J2SE 1.4 contain quite a few important facilities that had
been sorely lacking for years. In fact, NIO is probably the most
important package added to the language since Swing. In response,
Java NIO by Ron Hitchens explores this framework's components and
demonstrates their usage.
- Book: Java NIO
- Author: Ron Hitchens
- Publisher: O'Reilly
- ISBN: 0-596-00288-2
The first of the book's six chapters is a remarkably exhaustive survey
of the I/O features -- along with their underlying hardware interfaces --
in modern operating systems. For Java programmers who have been sheltered
from the gory details of virtual memory, kernel mode versus user mode, and
memory pages, this will be a truly revelatory experience. The next couple
of chapters cover Java NIO's core features such as buffers and channels.
Buffers are the primary means of data transportation in advanced I/O
operations, and channels serve as gateways through which I/O transfers
take place. The author then goes on to present the notion of selectors.
Selectors are used in readiness selection, whereby a single thread manages
multiple I/O channels simultaneously, yet efficiently.
The last sections of the book are dedicated to the novel features that
are included in the NIO package, although they're not directly related to
I/O. For example, Hitchens reviews the new regular expression API. Regular
expressions are widely used for scanning text data from file streams,
which makes them handy in I/O-bound applications. The reader will also
learn to deal with character sets, a topic that goes hand in hand with
text processing and display.
The over-protective environment of JVMs and sugar-coated APIs have
hidden from programmers what really happens under the hood of every modern
computing environment. To quote the author:
"The traditional I/O abstractions of Java... do not scale
when moving large amounts of data, nor do they provide some common I/O
functionality widely available on most operating systems
This common functionality includes nonblocking I/O, memory mapped
files, and scatter/gather I/O -- the nuts and bolts of every Linux kernel
hacker and C/C++ system programmer. Knowing how hard Java technology
creators have tried to abstract away low-level "implementation details"
from programmers, I suspect that NIO's complex concepts will flabbergast
quite a few readers. This is by no means anything to blame the author for,
though. In fact, Java NIO is a plausible compromise between the
need to know how real world I/O bound programs should be written and Java
technology's high-level abstractions.
NIO is a comprehensive and well-written guide to the new I/O
facilities and its concepts. Server-side Java programmers and designers of
advanced time-critical applications will certainly find it valuable and
Danny Kalev is a system analyst and software
engineer with 13 years of experience, specializing in C++ and
object-oriented analysis and design. He was a member of the ANSI C++
standardization committee between 1997-2001. Danny is the author of
ANSI/ISO C++ Professional Programmer's Handbook (Que, 1999, ISBN:
0789720221). Check out the DevX review here.
He can be reached at http://email@example.com.