/** * Ensures that the buffer is valid. * * @throws IOException if an IO error occurs */ private void ensureBuffer() throws IOException { if (offset >= maxOffset) { buffer(); } }
/** * Ensures that the buffer is valid. * * @throws IOException if an IO error occurs */ private void ensureBuffer() throws IOException { if (offset >= maxOffset) { buffer(); } }
/** * Constructor. * * @param input the underlying input stream * @param capacity the size of the buffer * @throws IOException if an IO occurs filling the first buffer */ public BufferedSeekInputStream(SeekInputStream input, int capacity) throws IOException { this.input = input; this.buffer = new byte[capacity]; buffer(); }
/** * Ensures that the buffer is valid. * * @throws IOException if an IO error occurs */ private void ensureBuffer() throws IOException { if (offset >= maxOffset) { buffer(); } }
/** * Constructor. * * @param input the underlying input stream * @param capacity the size of the buffer * @throws IOException if an IO occurs filling the first buffer */ public BufferedSeekInputStream(SeekInputStream input, int capacity) throws IOException { this.input = input; this.buffer = new byte[capacity]; buffer(); }
/** * Constructor. * * @param input the underlying input stream * @param capacity the size of the buffer * @throws IOException if an IO occurs filling the first buffer */ public BufferedSeekInputStream(SeekInputStream input, int capacity) throws IOException { this.input = input; this.buffer = new byte[capacity]; buffer(); }
/** * Positions the underlying stream at the given position, then refills * the buffer. * * @param p the position to set * @throws IOException if an IO error occurs */ private void positionDirect(long p) throws IOException { long newBlockStart = p / buffer.length * buffer.length; input.position(newBlockStart); buffer(); offset = (int)(p % buffer.length); }
/** * Positions the underlying stream at the given position, then refills * the buffer. * * @param p the position to set * @throws IOException if an IO error occurs */ private void positionDirect(long p) throws IOException { long newBlockStart = p / buffer.length * buffer.length; input.position(newBlockStart); buffer(); offset = (int)(p % buffer.length); }
/** * Positions the underlying stream at the given position, then refills * the buffer. * * @param p the position to set * @throws IOException if an IO error occurs */ private void positionDirect(long p) throws IOException { long newBlockStart = p / buffer.length * buffer.length; input.position(newBlockStart); buffer(); offset = (int)(p % buffer.length); }