You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Sungwon Jung <th...@gmail.com> on 2007/09/28 03:24:47 UTC

ByteBuffer.put()

Hello. I'm using MINA 1.1.2.

I want get packet with fixed size and put packet with fixed size.

example,
I received packet with 11byte header + 5byte data. (5 byte data is variable)
and I parsed header, data size is 5.
so how can I get 5 byte data?
and how can I put 5 byte data in ByteBuffer?

sorry, my English is poor.

Re: ByteBuffer.put()

Posted by Maarten Bosteels <mb...@gmail.com>.
Hello Sungwon,

Please read http://mina.apache.org/tutorial-on-protocolcodecfilter.html

Writing 5 bytes of data:

    ByteBuffer buffer = ByteBuffer.allocate(100);
    byte myData[] = new byte[] { 1,2,3,4,5 };
    buffer.put(myData);

Maarten

On 9/28/07, Sungwon Jung <th...@gmail.com> wrote:
> Hello. I'm using MINA 1.1.2.
>
> I want get packet with fixed size and put packet with fixed size.
>
> example,
> I received packet with 11byte header + 5byte data. (5 byte data is variable)
> and I parsed header, data size is 5.
> so how can I get 5 byte data?
> and how can I put 5 byte data in ByteBuffer?
>
> sorry, my English is poor.
>