public static long copy ( InputStream input , OutputStream output ) throws IOException { byte [ ] buffer = new byte [ 2 * 1024 ] ; long total = 0 ; int count ; while ( ( count = input . read ( buffer ) ) != - 1 ) { output . write ( buffer , 0 , count ) ; total += count ; } return total ; }
Copies all data from an InputStream to an OutputStream .