In this tutorial, we will discuss how to creates a buffer using byte array. The ByteBuffer
class is a container for handling data.The ByteBuffer class is available in java.nio package.
The java.nio.ByteBuffer class extends java.nio.Buffer class. It provides the following methods:
| Return type | Method | Description |
| static ByteBuffer | wrap(byte array) | The wrap method create a byte buffer by wrapping the associated byte arrray. |
| final int | capacity() | The capacity() method returns the capacity of associated buffer. |
import java.nio.*;
|
| C:\>java ByteArrayBuffer
C:\Work\Bharat\load\ByteArrayBuffedr\bharat.txt Name of file :C:\Work\Bharat\load\ByteArrayBuffedr\bharat.txt Capacity of ByteArraytBuffer : 255 |
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.