Getting started with NIO

The new input/output (NIO) library was introduced with JDK 1.4. Picking up where original I/O leaves off, NIO provides high-speed, block-oriented I/O in standard Java code. By defining classes to hold data, and by processing that data in blocks, NIO takes advantage of low-level optimizations in a way that the original I/O package could not, without using native code.

In this tutorial, we’ll cover almost every aspect of the NIO library, from the high-level conceptual stuff to under-the-hood programming detail. In addition to learning about crucial I/O elements like buffers and channels, you’ll have the opportunity to see how standard I/O works in the updated library. You’ll also learn about things you can only do with NIO, such as asynchronous I/O and direct buffers.

Throughout the tutorial, we’ll work with code samples that illustrate different aspects of the NIO library. Almost every code sample is part of an extended Java program, which you’ll find in Resources on page 38 . As you are working through the exercises, you’re encouraged to download, compile, and run these programs on your own system. The code will also come in handy when you’re done with the tutorial, providing a starting point for your NIO programming efforts.

This tutorial is intended for any programmer who wants to learn more about the JDK 1.4 NIO library. To get the most from the discussion you should understand basic Java programming concepts such as classes, inheritance, and using packages. Some familiarity with the original I/O library (from the java.io.* package) will also be helpful.

While this tutorial does require a working vocabulary and conceptual understanding of the Java language, it does not require a lot of actual programming experience. In addition to explaining thoroughly all the concepts relevant to the tutorial, I’ve kept the code examples fairly small and simple. The goal is to provide an easy entry point for learning about NIO, even for those who don’t have much Java programming experience.

Get pdf download Getting started with NIO

Related Tutorial

Tags: , , , , , , , , , , , , , , , , , ,

Comments

Leave a Reply