public synchronized int get ( byte [ ] dst , int off , int len ) { if ( available == 0 ) { return 0 ; } // limit is last index to read + 1 int limit = idxGet < idxPut ? idxPut : capacity ; int count = Math . min ( limit - idxGet , len ) ; System . arraycopy ( buffer , idxGet , dst , off , count ) ; idxGet += count ; if ( idxGet == capacity ) { // Array end reached, check if we have more int count2 = Math . min ( len - count , idxPut ) ; if ( count2 > 0 ) { System . arraycopy ( buffer , 0 , dst , off + count , count2 ) ; idxGet = count2 ; count += count2 ; } else { idxGet = 0 ; } } available -= count ; return count ; }
Gets as many of the requested bytes as available from this buffer .