Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Getting started with new I/O (NIO)

Greg Travis (mito@panix.com), Java programmer and technology writer
Greg Travis is a freelance Java programmer and technology writer living in New York City. Greg started his programming career in 1992, spending three years in the world of high-end PC games. In 1995, he joined EarthWeb, where he began developing new technologies with the Java programming language. Since 1997, Greg has been a consultant in a variety of Web technologies, specializing in real-time graphics and sound. His interests include algorithm optimization, programming language design, signal processing (with emphasis on music), and real-time 3D graphics. Other articles by Greg can be found on his personal Web page. He is also the author of JDK 1.4 Tutorial, published by Manning Publications.

For technical questions or comments about the content of this tutorial, contact Greg Travis at mito@panix.com.

Summary:  The new input/output (NIO) library, introduced with JDK 1.4, provides high-speed, block-oriented I/O in standard Java code. This hands-on tutorial covers the NIO library in great detail, from the high-level concepts to under-the-hood programming detail. You'll learn about crucial I/O elements like buffers and channels, and examine how standard I/O works in the updated library. You'll also learn about things you can do only with NIO, such as asynchronous I/O and direct buffers.

Date:  09 Jul 2003
Level:  Introductory PDF:  A4 and Letter (145 KB | 34 pages)Get Adobe® Reader®

Activity:  56246 views
Comments:  

Resources

Learn

  • See the SDK Documentation for more information about installing and configuring JDK 1.4.

  • Sun's guide to the new I/O APIs provides a thorough introduction to NIO, including some minor elements not covered in this tutorial.

  • The online API specification describes the classes and methods of NIO, in the autodoc format that you know and love.

  • JSR 51 is the Java Community Process document that first specified the new features of NIO. In fact, NIO, as implemented in JDK 1.4, is a subset of the features described in this document.

  • Want a thorough introduction to stream I/O (including problems, solutions, and the introduction of NIO)? You couldn't do better than Merlin Hughes's " Turning streams inside out " ( developerWorks, July 2002).

  • Of course, you could also just take the tutorial. " Introduction to Java I/O " ( developerWorks, April 2000) covers all the basics of Java I/O prior to JDK 1.4.

  • John Zukowski has written some good articles about NIO for his Magic with Merlin column:
  • Get a little deeper into NIO with Aruna Kalagnanam and Balu G's " Merlin brings nonblocking I/O to the Java platform " ( developerWorks, March 2002).

  • Greg Travis examines NIO in his book, JDK 1.4 Tutorial (Manning Publications, March 2002).

  • You'll find hundreds of articles about every aspect of Java programming in the developerWorks Java technology zone.

Get products and technologies

  • Download nio-src.zip, the complete source for the examples in this tutorial.

12 of 13 | Previous | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Java technology
ArticleID=482400
TutorialTitle=Getting started with new I/O (NIO)
publish-date=07092003
author1-email=mito@panix.com
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Special offers