This post show you how to use the java.nio
buffer such as ByteBuffer
, CharBuffer
, DoubleBuffer
, etc. To create a buffer you can use the allocate(int capacity)
method. Each buffer object has the allocate(int capacity)
method. You need to pass the value of the capacity of the buffer to be created when calling this method.
package org.kodejava.io;
import java.nio.*;
public class BufferAllocate {
public static void main(String[] args) {
ByteBuffer byteBuffer = ByteBuffer.allocate(64);
CharBuffer charBuffer = CharBuffer.allocate(64);
ShortBuffer shortBuffer = ShortBuffer.allocate(64);
IntBuffer intBuffer = IntBuffer.allocate(64);
LongBuffer longBuffer = LongBuffer.allocate(64);
FloatBuffer floatBuffer = FloatBuffer.allocate(64);
DoubleBuffer doubleBuffer = DoubleBuffer.allocate(64);
}
}
Latest posts by Wayan (see all)
- How do I create a table with multiple header in iText 8? - March 16, 2024
- How do I add Image to a Table in iText 8? - March 11, 2024
- How do I downgrade Android SDK emulator version? - February 12, 2024