public static int pipeBytes ( InputStream in , OutputStream out , byte [ ] buffer ) throws IOException { int count = 0 ; int length ; while ( ( length = ( in . read ( buffer ) ) ) >= 0 ) { out . write ( buffer , 0 , length ) ; count += length ; } return count ; }
Reads the specified input stream into the provided byte array storage and writes it to the output stream .