In this tutorial, we will see how to writes the byte into byte buffer
by using
put(byte b) method of ByteBuffer class.
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 | put(byte b) | The put(..) method write byte into associated buffer and increment position. |
| abstract byte | get() | The get() method read byte from current position and increment position. |
import java.nio.*;
|
| C:\>java PutByte Contents of buffer :123456789 |
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.