Return-Path: Delivered-To: apmail-hc-dev-archive@www.apache.org Received: (qmail 52275 invoked from network); 28 Dec 2010 13:56:28 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 28 Dec 2010 13:56:28 -0000 Received: (qmail 15579 invoked by uid 500); 28 Dec 2010 13:56:27 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 15384 invoked by uid 500); 28 Dec 2010 13:56:27 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 15376 invoked by uid 99); 28 Dec 2010 13:56:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Dec 2010 13:56:26 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of work@vaisberg.de designates 80.67.18.16 as permitted sender) Received: from [80.67.18.16] (HELO smtprelay04.ispgateway.de) (80.67.18.16) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Dec 2010 13:56:17 +0000 Received: from [84.152.190.94] (helo=[192.168.2.126]) by smtprelay04.ispgateway.de with esmtpa (Exim 4.68) (envelope-from ) id 1PXa1s-0003H6-Ok for dev@hc.apache.org; Tue, 28 Dec 2010 14:55:57 +0100 Message-ID: <4D19EC6A.6080708@vaisberg.de> Date: Tue, 28 Dec 2010 14:55:54 +0100 From: Alexander Vaysberg User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 MIME-Version: 1.0 To: HttpComponents Project Subject: Re: Clearing the ByteBuffer References: In-Reply-To: X-Enigmail-Version: 1.1.2 Content-Type: multipart/alternative; boundary="------------040001070407030004050405" X-Df-Sender: 048996 X-Virus-Checked: Checked by ClamAV on apache.org --------------040001070407030004050405 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 > --------------040001070407030004050405--