Here you can find the source of toFloat(ByteBuffer buffer)
public static float toFloat(ByteBuffer buffer)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { public static float toFloat(byte[] bytes) { return toFloat(ByteBuffer.wrap(bytes)); }// w w w. j a v a 2s . c o m public static float toFloat(ByteBuffer buffer) { return toByteBuffer(buffer, Float.BYTES).getFloat(); } protected static ByteBuffer toByteBuffer(ByteBuffer buffer, int length) { if (length > buffer.remaining()) { return (ByteBuffer) ((ByteBuffer) ByteBuffer.allocate(length).position(length - buffer.remaining())) .put(buffer.array()).rewind(); } else { return buffer; } } }