public static Binary read ( InputStream in , int len ) throws IOException { byte [ ] bytes = new byte [ len ] ; int pos = 0 ; while ( pos < len ) { int i = in . read ( bytes , pos , len - pos ) ; if ( i <= 0 ) { throw new IOException ( "End of stream before complete buffer read." ) ; } pos += i ; } return wrap ( bytes ) ; }
Read a binary buffer from input stream .