public static int copy ( InputStream input , OutputStream output ) throws IOException { byte [ ] buffer = new byte [ BUFFER_SIZE ] ; BufferedInputStream in = new BufferedInputStream ( input , BUFFER_SIZE ) ; BufferedOutputStream out = new BufferedOutputStream ( output , BUFFER_SIZE ) ; int count = 0 , n = 0 ; try { while ( ( n = in . read ( buffer , 0 , BUFFER_SIZE ) ) != - 1 ) { out . write ( buffer , 0 , n ) ; count += n ; } out . flush ( ) ; } finally { IOUtils . closeQuietly ( in ) ; IOUtils . closeQuietly ( out ) ; } return count ; }
Copies bytes from the input stream to the output stream