This should work in JAVA mode but since it uses native libraries it probaly won't work in JAVASCRIPT or ANDROID modes.
Assuming you have a byte array called
b[] then to read this as a series of doubles
- import java.nio.*;
- ByteBuffer buf = ByteBuffer.wrap(b);
- // The default ByteOrder is BIG_ENDIAN but depending on the source of
- // the byte array you may have to change it to LITTLE_ENDIAN
- // Only add the next line if it proves neccessary
- buf.order(ByteOrder.LITTLE_ENDIAN);
- // Each double requires 8 bytes make a double array big enough
- double[] darray = new double(b.length / 8);
- for(int i = 0; i < darray.length; i++){
- darray[i] = buf.readDouble();
- }