I have a byte array sent via UDP from x-plane. The bytes (4) are all floats or integers… I tried to cast them to floats but no luck so far…
Example array: byte d
You cannot just cast them into a float/int. You have to convert the bytes into an int or float.
Here is one simple way to do it:
byte [] data = new byte[] {1,2,3,4};
ByteBuffer b = ByteBuffer.wrap(data);
System.out.println(b.getInt());
System.out.println(b.getFloat());
There is a reasonable discussion here:
http://www.velocityreviews.com/forums/t129791-convert-a-byte-array-to-a-float.html