Java Convert via ByteBuffer toFloat(byte[] bytes)

Here you can find the source of toFloat(byte[] bytes)

Description

Converts a byte array to a float value

License

Apache License

Parameter

Parameter Description
bytes a parameter

Return

the long value

Declaration

public static float toFloat(byte[] bytes) 

Method Source Code

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

import java.nio.ByteBuffer;

public class Main {
    /**//from   ww  w  .  ja va 2s  .c o m
     * Converts a byte array to a float value
     * @param bytes
     * @return the long value
     */
    public static float toFloat(byte[] bytes) {
        if (bytes == null || bytes.length == 0) {
            return -1L;
        }
        return ByteBuffer.wrap(bytes).getFloat();
    }
}

Related

  1. toDirectBuffer(String s)
  2. toDoubleArray(byte[] data)
  3. toFile(URL url)
  4. toFile(URL url)
  5. toFiles(URL[] urls)
  6. toFloat(final byte[] b)
  7. toFloatArray(int[] intArray)
  8. toFloatBytes(List datas)
  9. toGuidBytes(UUID theUuid)