public static void streamCopy(final InputStream in, final FileChannel out,
        final ProgressBar progressBar) throws IOException {
        NullArgumentException.validateNotNull(in, "Input stream");
        NullArgumentException.validateNotNull(out, "Output stream");
        final long start = System.currentTimeMillis();
        long bytes = 0;
        ProgressBar feedbackBar = progressBar;
        if (feedbackBar == null) {
            feedbackBar = new NullProgressBar();
        }
        try {
            ReadableByteChannel inChannel = Channels.newChannel(in);
            bytes = out.transferFrom(inChannel, 0, Integer.MAX_VALUE);
            inChannel.close();
        }
        finally {
            feedbackBar.increment(bytes, bytes / Math.max(System.currentTimeMillis() - start, 1));
            feedbackBar.stop();
        }
    }
public static void streamCopy ( final InputStream in , final FileChannel out , final ProgressBar progressBar ) throws IOException { NullArgumentException . validateNotNull ( in , "Input stream" ) ; NullArgumentException . validateNotNull ( out , "Output stream" ) ; final long start = System . currentTimeMillis ( ) ; long bytes = 0 ; ProgressBar feedbackBar = progressBar ; if ( feedbackBar == null ) { feedbackBar = new NullProgressBar ( ) ; } try { ReadableByteChannel inChannel = Channels . newChannel ( in ) ; bytes = out . transferFrom ( inChannel , 0 , Integer . MAX_VALUE ) ; inChannel . close ( ) ; } finally { feedbackBar . increment ( bytes , bytes / Math . max ( System . currentTimeMillis ( ) - start , 1 ) ) ; feedbackBar . stop ( ) ; } }
Copy a stream to a destination. It does not close the streams.

@param in
the stream to copy from
@param out
the stream to copy to
@param progressBar
download progress feedback. Can be null.

@throws IOException
re-thrown