/** * Seeks to the given position. This method avoids re-filling the buffer * if at all possible. * * @param p the position to set * @throws IOException if an IO error occurs */ public void position(long p) throws IOException { long blockStart = (input.position() - maxOffset) / buffer.length * buffer.length; long blockEnd = blockStart + maxOffset; if ((p >= blockStart) && (p < blockEnd)) { // Desired position is somewhere inside current buffer long adj = p - blockStart; offset = (int)adj; return; } positionDirect(p); }
/** * Seeks to the given position. This method avoids re-filling the buffer * if at all possible. * * @param p the position to set * @throws IOException if an IO error occurs */ public void position(long p) throws IOException { long blockStart = (input.position() - maxOffset) / buffer.length * buffer.length; long blockEnd = blockStart + maxOffset; if ((p >= blockStart) && (p < blockEnd)) { // Desired position is somewhere inside current buffer long adj = p - blockStart; offset = (int)adj; return; } positionDirect(p); }
/** * Seeks to the given position. This method avoids re-filling the buffer * if at all possible. * * @param p the position to set * @throws IOException if an IO error occurs */ public void position(long p) throws IOException { long blockStart = (input.position() - maxOffset) / buffer.length * buffer.length; long blockEnd = blockStart + maxOffset; if ((p >= blockStart) && (p < blockEnd)) { // Desired position is somewhere inside current buffer long adj = p - blockStart; offset = (int)adj; return; } positionDirect(p); }