Re: Writing Binaries to and Reading Binaries from Disk
Eric Sosman wrote:
Elsethread, the O.P. has explained that the data will be
consumed by a C program that expects to read a "native" format.
I'm not finding that. I'm only finding:
How do you do that in Java,
write binary <short>s to disk and then later read in
those <short>s from disk again?
I guess I could convert each <short> to a <byte> array and then call
<write( toDiskArray, 0, 2)>, and then call
<read( fromDiskArray, 0, 2)>, and then convert <fromDiskArray> back
into a <short>,
after going back about a month's worth through clj.programmer and clj.help for
posts by the OP in any thread.
The only reference in this thread to reading by other programs was not from
the OP but from Lothar Kimmeringer, which is why Patricia asked him about the
advantages of little-endian storage, a question he has yet to answer.
As Roedy Green said in this thread:
There['s] another thread about little-endian, big-endian which you might
be conflating with this one. O.P. just wanted to write out some values
and read them back. That would naturally be done in big-endian with
DataOutputStream. DataOutputStream always writes big-endian,
independent of the endianness of the platform.
It looks like that other thread, the one you must be misremembering, Eric, is
in clj.help from Alexandre Ferrieux, "How to (efficiently) write an int array
into a file ?" [sic] 2009-09-25 at 21:14Z:
How do we accomplish this simple task of a direct write to disk of a
big (packed) array of ints, in native byte order ? [sic]