private int ensureBuffer() throws IOException { if (!buffer.hasRemaining()) { buffer.clear(); wrapped.read(buffer); buffer.flip(); } return buffer.remaining(); }
@Override public int read(ByteBuffer dst) throws IOException { requireOpen(); buffer.limit(0); wrapped.position(position); int read = wrapped.read(dst); if (read > 0) { position += read; } return read; }