this tutorial, we will discuss how to get value of a given index from buffer. The ByteBuffer
class is a container for handling data. The get(int index) method of ByteBuffer class returns value
of a given index. The method allocate( int capacity) creates a new byte buffer, and the current position
will be zero and its limit will be it's capacity.
About ByteBuffer API:
The java.nio.ByteBuffer class extends java.nio.Buffer class. It provides the following methods:
|static ByteBuffer||allocate( int capacity)||The allocate() method create a byte buffer of specified capacity.|
|byte||get(int index)||The get() method reads bytes at given index from buffer.|
|C:\Work\Bharat\load\getSpecified value>java GetIndexValue
Value in first buffer at index 4 : r
Value in second buffer at index 4 : a
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.