Vadim Gritsenko wrote:
[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.
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