Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

little endian DataInputStream

Tags:

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.

like image 963
Saideira Avatar asked May 02 '11 20:05

Saideira


People also ask

What is the DataInputStream?

Class DataInputStream. A data input stream lets an application read primitive Java data types from an underlying input stream in a machine-independent way. An application uses a data output stream to write data that can later be read by a data input stream.

How do you use DataInputStream?

InputStream in = new DataInputStream(InputStream in); Once you have DataInputStream object in hand, then there is a list of helper methods, which can be used to read the stream or to do other operations on the stream. Sr.No. Reads up to len bytes of data from the input stream into an array of bytes.


1 Answers

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

like image 148
Peter Lawrey Avatar answered Nov 22 '22 05:11

Peter Lawrey