Saideira
Saideira

Reputation: 2404

little endian DataInputStream

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

Answers (2)

Peter Lawrey
Peter Lawrey

Reputation: 533482

Perhaps you can use ByteBuffer which allows order(ByteOrder.LITTLE_ENDIAN) After that most of the methods are like DataInputStream.

Upvotes: 29

Luna
Luna

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

Related Questions