hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Vaysberg <w...@vaisberg.de>
Subject Re: Clearing the ByteBuffer
Date Tue, 28 Dec 2010 13:55:54 GMT
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: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message