Is it possible to use the ByteBuffer#clear() method?

Thanks,
Supun..

On Tue, Dec 28, 2010 at 7:25 PM, Alexander Vaysberg <[email protected]> wrote:
> you can using flip and compact method for this:
>
> ByteBuffer buffer = ByteBuffer.allocate(1024*1024);
>
>    int end = 0;
>
>    while (end >= 0 || buffer.hasRemaining( )) {
>
>      if (end != -1) end = inChannel.read(buffer);
>
>        buffer.flip( );
>
>        ...
>
>        buffer.compact( );
>
>    }
>
>
>
> Am 28.12.2010 13:21, schrieb Supun Kamburugamuva:
>> I would like to reuse the ByteBuffer that is allocated for a request.
>> Is it possible to clear the buffer after the decoder/encoder completed
>> and use the same buffer for another request? I'm using HTTPCore-NIO.
>>
>> Thanks,
>> Supun...
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>
>



-- 
Technical Lead, WSO2 Inc
http://wso2.org
supunk.blogspot.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to