In this tutorial, we will see how to read float value from a 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 | putFloat() | The putFloat(..) method write four byte containing the given float value into associated buffer. |
| abstract float | getFloat() | The getFloat() method read four byte from current position and increment position by four. |
import java.nio.*;
|
| C:\>java GetFloatValue Float data into byte buffer : 221255.02 |
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.