Reputation: 2404
Is there any way to force DataInputStream to read little-endian data?? Thx
PS. Doing byte-buffer conversions is not very convinient as I'm dealing with C-type structs that have lots of 32-bit and 16-bit members.
Upvotes: 23
Views: 18205
Reputation: 533482
Perhaps you can use ByteBuffer
which allows order(ByteOrder.LITTLE_ENDIAN)
After that most of the methods are like DataInputStream
.
Upvotes: 29
Reputation: 1488
Guava now includes LittleEndianDataInputStream and LittleEndianDataOutputStream.
If you aren't already using Guava Peter Lawrey's answer above is probably better.
Upvotes: 20