JDK 1.4 Tutorial, eDoc 1 : Exploring Channels and Buffers in the New I/O
Book Details
Description
The New I/O (NIO) Library included in JDK 1.4 represents a revolution in the way that Java programs read and write data. The new channel and buffer classes allow for production-level efficiency while still maintaining full cross-platform portability. And if you think you won't use them, think again -- the stream classes have been re-implemented on top of NIO.
This e-doc will guide you through the nitty-gritty of the new channel and buffer classes, showing you how they work and how to use them to accomplish staple I/O tasks. It also outlines some of the exciting new features that are made possible by NIO -- including memory-mapped files and non-blocking I/O.
This e-doc will show you how to:
- Create and use channels and buffers
- Access efficient system-level I/O buffers
- Lock files and portions of files
- Copy files quickly
- Use MappedByteBuffers
- Translate text data between different encodings
- Determine what network interfaces exist on a computer
Sample programs included in this chapter:
- A network TCP/IP forwarder
- A simple database that uses file locking
- A chat (instant messaging) server, implemented efficiently using selectors
- A utility for converting data between any two charsets






