In this tutorial, we will see how to creates a view of this byte buffer as a char 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 Charbuffer | asCharBuffer() | The asCharBuffer() method creates a view of byte buffer as a char buffer. |
| int | limit() | The limit() method returns the limit of associated buffer. |
| int | position() | The position() method returns the position of associated buffer. |
| final int | capacity() | The capacity() method returns the capacity of associated buffer. |
import java.io.File;
|
| C:\>java AsCharBuffer Information related to byte buffer : Limit = 256 position = 0 capacity = 256 Information related to char buffer : Limit = 128 position = 0 capacity = 128 |
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.