cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leszek Gawron <lgaw...@mobilebox.pl>
Subject Re: svn commit: r439744 - in /cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer: ./ monolithic/ utils/
Date Wed, 20 Sep 2006 07:54:59 GMT
Vadim Gritsenko wrote:
> lgawron@apache.org wrote:
>> +public class CopyUtils {
>> +    public static void copy( InputStream is, OutputStream os ) throws 
>> IOException {
>> +        if ( !(is instanceof BufferedInputStream) ) {
>> +            is = new BufferedInputStream( is );
>> +        }
>> +        if ( !(os instanceof BufferedOutputStream) ) {
>> +            os = new BufferedOutputStream( os );
>> +        }
>> +        +        try {
>> +            IOUtils.copy(is, os);
>> +        } finally {
>> +            IOUtils.closeQuietly(is);
>> +            IOUtils.closeQuietly(os);
>> +        }
>> +    }
>> +}
> 
> I guess that's what one would call "triple buffering", isn't it?
> 
> IOUtils uses 4Kb buffer, BufferedInputStream creates buffer 2Kb to 8Kb 
> depending on Java version, and BufferedOutputStream's buffer varies from 
> 512b to 8Kb. By the time data is copied, it changes hands 4 times - and 
> two of those are extra.
I removed stream wrapping. Thank you for the explanation.

-- 
Leszek Gawron, IT Manager                          MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

Mime
View raw message