/** * Reposition the stream. * * @param p the new position for this stream * @throws IOException if an IO error occurs */ public void position(long p) throws IOException { if (p < 0) { throw new IOException("Negative seek offset."); } if (p > size) { throw new IOException("Desired position exceeds size."); } if (p < buffer.length) { // Only seek file if necessary if (position > buffer.length) { diskStream.position(0); } } else { diskStream.position(p - buffer.length); } this.position = p; }
/** * Reposition the stream. * * @param p the new position for this stream * @throws IOException if an IO error occurs */ public void position(long p) throws IOException { if (p < 0) { throw new IOException("Negative seek offset."); } if (p > size) { throw new IOException("Desired position exceeds size."); } if (p < buffer.length) { // Only seek file if necessary if (position > buffer.length) { diskStream.position(0); } } else { diskStream.position(p - buffer.length); } this.position = p; }
/** * Reposition the stream. * * @param p the new position for this stream * @throws IOException if an IO error occurs */ public void position(long p) throws IOException { if (p < 0) { throw new IOException("Negative seek offset."); } if (p > size) { throw new IOException("Desired position exceeds size."); } if (p < buffer.length) { // Only seek file if necessary if (position > buffer.length) { diskStream.position(0); } } else { diskStream.position(p - buffer.length); } this.position = p; }