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