Java NiO Buffers

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.