cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vadim Gritsenko <va...@reverycodes.com>
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 03:26:26 GMT
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.

Vadim

Mime
View raw message