public byte [ ] readByteArray ( int len ) { if ( available ( ) < len ) { throw new RuntimeException ( "not enough data available, check available() > len before calling" ) ; } byte b [ ] = new byte [ len ] ; int count = 0 ; while ( pollIndex != addIndex && count < len ) { b [ count ++ ] = storage . get ( pollIndex ++ ) ; if ( pollIndex >= storage . length ( ) ) { pollIndex = 0 ; } } return b ; }
convenience method to read len byte array . Throws an excpetion if not enough data is present