@Test
  public void testSeek() throws Exception {
    File file = system.createFile("testFile1");

    ByteArrayOutputStream expected = new ByteArrayOutputStream();
    byte[] data = new byte[SMALL_CHUNK];

    // Write multiple times to the file with a lot of small chunks
    while (expected.size() < FileSystem.CHUNK_SIZE + 1) {
      rand.nextBytes(data);

      expected.write(data);
      writeBytes(file, data);
    }

    byte[] expectedBytes = expected.toByteArray();
    assertContents(expectedBytes, file);

    // Assert that there are only 2 chunks in the system, since we wrote just
    // past the end of the first chunk.
    assertEquals(2, numberOfChunks(fileAndChunkRegion));

    SeekableInputStream in = file.getInputStream();

    // Seek to several positions in the first chunk
    checkByte(5, in, expectedBytes);
    checkByte(50, in, expectedBytes);
    checkByte(103, in, expectedBytes);
    checkByte(1, in, expectedBytes);

    // Seek back and forth between chunks
    checkByte(FileSystem.CHUNK_SIZE + 2, in, expectedBytes);
    checkByte(23, in, expectedBytes);
    checkByte(FileSystem.CHUNK_SIZE + 10, in, expectedBytes);
    checkByte(1023, in, expectedBytes);

    // Read the remaining data after a seek

    in.seek(10);
    byte[] results = new byte[expectedBytes.length];

    // Fill in the initial 10 bytes with the expected value
    System.arraycopy(expectedBytes, 0, results, 0, 10);

    assertEquals(results.length - 10, in.read(results, 10, results.length - 10));
    assertEquals(-1, in.read());

    assertArrayEquals(expectedBytes, results);
  }
A test that skip can jump to the correct position in the stream
geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/filesystem/FileSystemJUnitTest.java