mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niklas Therning <nik...@trillian.se>
Subject Re: ByteBuffer.order(ByteOrder.LITTLE_ENDIAN); //bug?
Date Thu, 15 Jun 2006 06:48:07 GMT
netsql wrote:
> seams to work most of the time.
> 
> But when the stream has:
> 61 05 00 00 and I get as byte[4]
> I get 6105 and should get 561.

No, you should get {61,05, 00, 00}. :) get(byte[] dst) will get byte by
byte thus the current byte order doesn't apply at all. In fact MINA just
calls java.nio.ByteBuffer.get(byte[] dst, int offset, int length). From
Sun's docs for that method:

... an invocation of this method of the form src.get(dst, off, len) has
exactly the same effect as the loop

     for (int i = off; i < off + len; i++)
         dst[i] = src.get();

I think you need to call getInt() for the byte order to be used.

-- 
Niklas Therning
Software Architect
www.spamdrain.net

Mime
View raw message