/** * Gets data from the ring buffer. * * @return The number of bytes read. This is guaranteed to be * <code>min(len, getUsed())</code>. */ public int get(byte[] buf, int pos, int len) { if (len < 0) { throw new IllegalArgumentException(); } int trLen1 = Math.min(len, Math.min(rBufUsed, rBufSize - rBufPos)); remove(buf, pos, trLen1); int trLen2 = Math.min(len - trLen1, rBufUsed); remove(buf, pos + trLen1, trLen2); return trLen1 + trLen2; }
/** * Gets data from the ring buffer. * * @return The number of bytes read. This is guaranteed to be * <code>min(len, getUsed())</code>. */ public int get(byte[] buf, int pos, int len) { if (len < 0) { throw new IllegalArgumentException(); } int trLen1 = Math.min(len, Math.min(rBufUsed, rBufSize - rBufPos)); remove(buf, pos, trLen1); int trLen2 = Math.min(len - trLen1, rBufUsed); remove(buf, pos + trLen1, trLen2); return trLen1 + trLen2; }