In this tutorial, we will see how to write the given character into byte buffer.
ByteBuffer API:
The java.nio.ByteBuffer class extends java.nio.Buffer class. It provides the following methods:
| Return type | Method | Description |
| static ByteBuffer | allocate( int capacity) | The allocate(..)method allocate a new byte buffer. |
| abstract ByteBuffer | putChar(char value) | The putChar(..) method write two byte containing the given character value into associated buffer. |
| abstract char | getChar() | The getChar() method read 2 byte from current position and increment position. |
import java.nio.*;
|
| :\>java BytePutChar java.nio.HeapByteBuffer[pos=12 lim=256 cap=256] Character data in byte buffer : Bharat |
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.