public static long copy ( final InputStream in , final OutputStream out ) throws IOException { Objects . requireNonNull ( in ) ; Objects . requireNonNull ( out ) ; final byte [ ] buffer = new byte [ COPY_BUFFER_SIZE ] ; long result = 0 ; int rc ; while ( ( rc = in . read ( buffer ) ) >= 0 ) { result += rc ; out . write ( buffer , 0 , rc ) ; } return result ; }
Copy the remaining content of one stream to the other