The Java NiO buffer
Java's traditional I/O model is oriented towards a single byte, which abstracts the input output into a stream of bytes or characters. This single-byte read or write model is less efficient and does not conform to the I/O characteristics of the operating system. The IO of the operating system is byte-oriented, typically reading a piece of data directly from the disk into memory or writing a piece of data to disk. Java NIO provides buffers to read and write byte blocks.
Within buffer, an array is managed and the data is stored in an array. Buffer is used as a carrier of data, and Java programs communicate with the outside world via buffer when using NIO.
I. Categories of buffers
As shown, in addition to the Boolean type, Java provides the appropriate buffer for the other seven basic types. Of these seven kinds of buffer, Bytebuffer is the most basic buffer, and the other classes of buffer can be obtained by bytebuffer conversion. And when using the channel to transmit data externally, the requirement must be bytebuffer.
Two. Four properties of the buffer
Capacity
Java NiO Buffers