public static void copyInputToOutput(final InputStream input, final OutputStream output) throws IOException {
        final BufferedInputStream in = new BufferedInputStream(input);
        final BufferedOutputStream out = new BufferedOutputStream(output);
        final byte buffer[] = new byte[8192];
        for (int count = 0; count != -1;) {
            count = in.read(buffer, 0, 8192);
            if (count != -1) {
                out.write(buffer, 0, count);
            }
        }

        try {
            in.close();
            out.close();
        } catch (final IOException ex) {
            throw new IOException("Closing file streams, " + ex.getMessage());
        }
    }
public static void copyInputToOutput ( final InputStream input , final OutputStream output ) throws IOException { final BufferedInputStream in = new BufferedInputStream ( input ) ; final BufferedOutputStream out = new BufferedOutputStream ( output ) ; final byte buffer [ ] = new byte [ 8192 ] ; for ( int count = 0 ; count != - 1 ; ) { count = in . read ( buffer , 0 , 8192 ) ; if ( count != - 1 ) { out . write ( buffer , 0 , count ) ; } } try { in . close ( ) ; out . close ( ) ; } catch ( final IOException ex ) { throw new IOException ( "Closing file streams, " + ex . getMessage ( ) ) ; } }
Copy input stream to output stream using 8K buffer.