Java ByteBuffer to Float readFloat(ByteBuffer buffer)

Here you can find the source of readFloat(ByteBuffer buffer)

Description

read Float

License

LGPL

Declaration

public static float readFloat(ByteBuffer buffer) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.nio.ByteBuffer;

public class Main {
    public static float readFloat(ByteBuffer buffer) {
        return Float.intBitsToFloat(readInt(buffer));
    }/*w w  w  . ja  v a  2s .  c o  m*/

    public static int readInt(ByteBuffer buffer) {

        int i = buffer.get() & 0xff;
        i |= (buffer.get() & 0xff) << 8;
        i |= (buffer.get() & 0xff) << 16;
        i |= (buffer.get() & 0xff) << 24;
        return i;
    }
}

Related

  1. readFloatArray(ByteBuffer bb, int length)
  2. readFloats(final ByteBuffer bb, final int length)
  3. toFloat(AudioFormat format, ByteBuffer buf, float[] floatBuf)
  4. toFloat(ByteBuffer buffer)