Chapter 6
Buffers
NIO is based on buffers, whose contents are sent to or received from I/O services via channels. This chapter introduces you to NIO’s buffer classes.
Introducing Buffers
A buffer is an object that stores a fixed amount of data to be sent to or received from an I/O service (an operating system component for performing input/output). It sits between an application and a channel that writes the buffered data to the service or reads the data from the service and deposits it into the buffer.
Buffers possess four properties:
- Capacity: The total number of data items that can be stored in the buffer. The capacity is specified when the buffer is created and cannot be changed later.
- Limit: The zero-based index of the first element that ...
Get Java I/O, NIO and NIO.2 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.