import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
public class BytesToFloat {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
//float 类型值为123.456 以大端模式存储数据即高字节存于低地址,低字节存于高地址
byte bytes[]={0x42,(byte) 0xf6,(byte)0xE9,0x79};
//ByteArrayInputStream
,使用 buf
作为其缓冲区数组
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
DataInputStream dis=new DataInputStream(new ByteArrayInputStream(b));
float f=dis.readFloat();
dis.close();
System.out.println(f);
}
}