Last Updated: June 6, 2026
The java.nio package is Java's second-generation I/O API. It was added in Java 1.4 to address two limitations of the original java.io streams: streams move data one byte (or one char) at a time, and most stream operations block the calling thread until the work finishes. NIO replaces that model with buffers (chunks of data you read and write in bulk) and channels (two-way connections to files, sockets, and pipes), plus optional non-blocking and asynchronous modes. This lesson is the overview: what NIO is, why it exists, the three core abstractions, how buffers track their state, and how to decide between java.io and java.nio for everyday code. The two chapters after this go deeper on Path/Files and on FileChannel.