Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;

public class Main {
    public static float toFloatEx(byte[] b, int pos) {
        try {
            byte[] byteTmp = new byte[4];
            for (int i = 0; i < 4; i++) {
                byteTmp[i] = b[pos + i];
            }
            ByteBuffer bb = ByteBuffer.wrap(byteTmp);

            FloatBuffer fb = bb.asFloatBuffer();

            return fb.get();
        } catch (Exception e) {
            e.printStackTrace();
            return 0.0f;
        }

    }
}