[EMAIL PROTECTED] 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