### Question:
ResettableFileInputStream extends ResettableInputStream implements RemoteMarkable, LengthMeasurable { @Override public synchronized void seek(long newPos) throws IOException { logger.trace("Seek to position: {}", newPos); long relativeChange = newPos - position; if (relativeChange == 0) return; long newBufPos = buf.position() + relativeChange; if (newBufPos >= 0 && newBufPos < buf.limit()) { buf.position((int)newBufPos); } else { buf.clear(); buf.flip(); } decoder.reset(); chan.position(newPos); position = syncPosition = newPos; } ResettableFileInputStream(File file, PositionTracker tracker);  ResettableFileInputStream(File file, PositionTracker tracker,
                                   int bufSize, Charset charset); @Override synchronized int read(); @Override synchronized int read(byte[] b, int off, int len); @Override synchronized int readChar(); @Override void mark(); @Override void markPosition(long position); @Override long getMarkPosition(); @Override void reset(); @Override long length(); @Override long tell(); @Override synchronized void seek(long newPos); @Override void close(); static final int DEFAULT_BUF_SIZE; }### Answer:
@Test public void testSeek() throws IOException { int NUM_LINES = 1000; int LINE_LEN = 1000; generateData(file, Charsets.UTF_8, NUM_LINES, LINE_LEN); PositionTracker tracker = new DurablePositionTracker(meta, file.getPath()); ResettableInputStream in = new ResettableFileInputStream(file, tracker, 10 * LINE_LEN, Charsets.UTF_8); String line = ""; for (int i = 0; i < 9; i++) { line = readLine(in, LINE_LEN); } int lineNum = Integer.parseInt(line.substring(0, 10)); assertEquals(8, lineNum); long pos = in.tell(); in.seek(pos - 2 * LINE_LEN); line = readLine(in, LINE_LEN); lineNum = Integer.parseInt(line.substring(0, 10)); assertEquals(7, lineNum); in.seek(in.tell() + LINE_LEN); line = readLine(in, LINE_LEN); lineNum = Integer.parseInt(line.substring(0, 10)); assertEquals(9, lineNum); in.seek(in.tell() + 20 * LINE_LEN); line = readLine(in, LINE_LEN); lineNum = Integer.parseInt(line.substring(0, 10)); assertEquals(30, lineNum); in.seek(in.tell() - 25 * LINE_LEN); line = readLine(in, LINE_LEN); lineNum = Integer.parseInt(line.substring(0, 10)); assertEquals(6, lineNum); in.seek(100 * LINE_LEN); in.seek(0); in.seek(9 * LINE_LEN); assertEquals(9, Integer.parseInt(readLine(in, LINE_LEN).substring(0, 10))); assertEquals(10, Integer.parseInt(readLine(in, LINE_LEN).substring(0, 10))); assertEquals(11, Integer.parseInt(readLine(in, LINE_LEN).substring(0, 10))); }