The Java NIO buffer

Source: Internet
Author: User

The JAVA NIO is used when interacting with the channel. The channel reads the data into the buffer, and then we access the data from the buffer. When writing data, the data to be sent is first filled in the buffer in order. Basically, a buffer is just a list, and all of its elements are basic data types (usually byte-type).

Second, the implementation of the buffer has the following (Bytebuffer is more commonly used, here is only introduced Bytebuffer)

    • Bytebuffer
    • Charbuffer
    • DoubleBuffer
    • Floatbuffer
    • Intbuffer
    • Longbuffer
    • Shortbuffer

Iii. Statement of Bytebuffer

Bytebuffer Bytebuffer = bytebuffer.allocate (1024x768); // Set Buffer
Bytebuffer Bytebuffer = Bytebuffer.wrap ("hello". GetBytes ()); // Bring in Data
Bytebuffer Bytebuffer = Bytebuffer.allocatedirect (1024x768//  set memory directly

Iv. Basic Methods in Bytebuffer

// readable mode
// convert to byte[]
// Clear Cache
Bytebuffer.put ("hello"// put data
Bytebuffer.compareto (bytebuffer.allocate// compare 2 Bytebuffer

Five, basically use, this is it, the others are similar.

The Java NIO buffer

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.