Submitted On 30-APR-1998
xorxor
Our workaround was to copy the DataInputStream source code to create a
LittleEndianDataInputStream class. However, I also need little-endian support
in the RandomAccessFile class, and there's no easy workaround for that. If
these classes didn't have final methods, we could simply subclass them.
Submitted On 26-MAY-1998
wildboar
this would be useful for me too
Submitted On 23-SEP-1998
pifpafpuf
Things start to become worse as of jdk1.2, because
now the docs of DataInput require that all input
is big-endian, so that it is no longer allowed to
write a class which implements DataInput and
reads little-endian.
Please note that between the invention of the wheel
and Java there have been other things, in
particular software which wrote data in
little-endian.
Submitted On 25-OCT-1998
jfdutcher1
This 'big' endian, 'little' endian has been a curse
for me...I did the obvious, switched the bytes, but it did not give expected
result. If anyone has a nice work-a-around please advise....I need it
NOW.
Submitted On 17-NOV-1998
xorxor
To pifpafpuf:
Thanks for pointing that out. I was unaware of the JDK 1.2 changes in the
DataInput and DataOutput interfaces. I think it's a huge mistake to require
big-endian implementations of those interfaces. Why should the interfaces
require anything from the underlying implementations?
It's bad enough that the DataInputStream and DataOutputStream implementations
only support big-endian data. At least we can modify the source code to
support little-endian data. But with the new restrictions on DataInput and
DataOutput, we can't write *any* implementations that work with little-endian
data -- unless we ignore those restrictions.
Submitted On 28-JAN-1999
paulhill
I'm working with a file format which actually specifies a combination of big
and little endian bytes within the file. Anything which made this easy to deal
with would be worthwhile. Implementing the operation at the lowest level would
also cut down on the operational overhead of performing byte-swapping before
using the data.
Submitted On 27-MAY-2000
SWP
While I disagree with the original posters comments that
little-endian is more intuitive. (I find Big-endian to be
much easier to deal with.) I agree that methods should be
provided to read and write both ways. I also agree with
the decision to force Big-endian on DataInput and
DataOutput. This must be done to preserve compatibility of
those APIs. Having DataInput do something arbitrary would
break everything. Writing the implementations that xorxor
describes is exactly what they are trying to prevent. If
you want that level of little-endian support then a new
little-endian interface is required that always does things
the little-endian way. I would be settle for methods added
to the Integer class, etc. that would do a quick byte swap.
Submitted On 11-SEP-2000
rgd
What?! What possible reason could DataInput/DataOutput have
for specifying the byte order being written? Their job is
to take higher-level entities like ints and floats and
"serialize" them to a byte stream. The manner in which that
byte stream is structured should be up to the specific
implementation of DataInput/DataOutput. How else are we
supposed to be compatible with non-Java data streams??! Not
everything is a byte swap... what about reading VAX format
floats, for example?
Submitted On 18-SEP-2001
SWP
That's the whole point. Having DataInputStream and
DataOutputStream work defferently depending on the
implementation would mean that the two streams could not
talk to each other across platforms - totally
unacceptable. The format (e.g. VAX floats) should be
explicite. Perhaps this could work like the character
encodings? So the format can be specified. It is too late
to change the default behaviour though.
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|