public static void readFully ( InputStream in , ByteArrayOutputStream out , byte [ ] buffer ) { try { int numRead = 0 ; while ( ( numRead = in . read ( buffer , 0 , buffer . length ) ) != - 1 ) { out . write ( buffer , 0 , numRead ) ; } out . flush ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
Method used to read a protobuf input stream into a byte array