mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From netsql <cekven...@gmail.com>
Subject Re: ByteBuffer.order(ByteOrder.LITTLE_ENDIAN); //bug?
Date Thu, 15 Jun 2006 19:17:22 GMT
So is there a "get" method or a helper class that will take "data" out 
of the bytebuffer and "filp the bits" so that it's not little endian?

How would I go about it, or should I write my own?

tia,
.V

Niklas Therning wrote:
> 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.
> 


Mime
View raw message