How to convert a byte data stream to float, double ...
I input a binay data stream created by different platform. The data stream
has a sequence of different data type such 4 byte integer, 4 byte float ...
in its original binary format. I need to retrieve the data, and also deal
with different byte order problem.
I read the data into a byte first, then try to manupulate it, and reinterprete
it . I could read the value use DataInoutStream.readFloat() etc. to retrieve
the value directly, if I do not have the byte order problem. Therefore I
have to swab the byte order, before I can interpret the data.
With integer type of data, I can swab byte using shift operator (>>, <<).
But I do not know how to do byte swab to a float or double in Java.
In c or c++, it is quite easy to manupulate the bit and byte in memory, and
reinterpret it in whatever the way you want.
How can I do this in Java?