In this tutorial you will see how to creates a view of byte buffer as a float buffer.
In this tutorial you will see how to creates a view of byte buffer as a float buffer.In this tutorial, we will see how to creates a view of byte buffer as a float 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 FloatBuffer | asFloatBuffer() | The asFloatBuffer() method creates a view of byte buffer as a float 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;
ByteBuffer capacity = %4d%n",
FloatBuffer capacity = %4d%n",
|
C:\>java AsFloat Information related to byte buffer : ByteBuffer Limit = 256 ByteBuffer position = 0 ByteBuffer capacity = 256 Information related to float buffer : FloatBuffer Limit = 64 FloatBuffer position = 0 FloatBuffer capacity = 64 |