Return-Path: Delivered-To: apmail-commons-issues-archive@locus.apache.org Received: (qmail 22973 invoked from network); 6 Dec 2007 14:49:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Dec 2007 14:49:16 -0000 Received: (qmail 74730 invoked by uid 500); 6 Dec 2007 14:49:03 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 74627 invoked by uid 500); 6 Dec 2007 14:49:03 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 74594 invoked by uid 99); 6 Dec 2007 14:49:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Dec 2007 06:49:02 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Dec 2007 14:49:04 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 18CCA714243 for ; Thu, 6 Dec 2007 06:48:43 -0800 (PST) Message-ID: <26555703.1196952523075.JavaMail.jira@brutus> Date: Thu, 6 Dec 2007 06:48:43 -0800 (PST) From: "Nikunj Trivedi (JIRA)" To: issues@commons.apache.org Subject: [jira] Updated: (IO-137) Added method for getting InputStream from ByteArrayOutputStream & IOUtils avoiding unnecessary array allocation and copy In-Reply-To: <21899693.1195631803019.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/IO-137?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Nikunj Trivedi updated IO-137: ------------------------------ Attachment: baos_to_inputstream.patch Attached baos_to_inputstream.patch. I just replaced local machine paths with relative paths. Can anybody discuss/comment/commit on this? > Added method for getting InputStream from ByteArrayOutputStream & IOUtils avoiding unnecessary array allocation and copy > ------------------------------------------------------------------------------------------------------------------------ > > Key: IO-137 > URL: https://issues.apache.org/jira/browse/IO-137 > Project: Commons IO > Issue Type: New Feature > Components: Streams/Writers, Utilities > Affects Versions: 1.3.2 > Environment: Any OS with appropriate JVM > Reporter: Nikunj Trivedi > Fix For: 1.4 > > Attachments: baos_to_inputstream.patch, baos_toIstream.patch > > > Patch inclues following two methods and test cases for both. > 1) New Method: ByteArrayOutputStream.toInputStream > ByteArrayOutputStream exposes its byte buffers by toByteArray(), which creates a fresh buffer and copy existing data to it. > A new method toInputStream() available in patch returns the current contents of baos, as an InputStream, avoiding unnecessary allocation and copying. > 2) New Method: IOUtils.toFullyBufferedInputStream > There are situations where the InputStream source is available and it has to be passed to different modules for processing. > It is needed to fetch the full contents of the InputStream in internal buffer(IOUtils.toByteArray() ), convert this buffer to ByteArrayInputStream and use that stream instead. But this is wasteful since toByteArray() requires one fresh allocation and copy operation. > New method copies InputStream to ByteArrayOutputStream and returns baos.toInputStream(), avoiding unnecessary memory allocation and copy. > Testcases are available in respective classes. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.