How do I keep a file open for reading
<p>I want to be able to open a (very large) file and read data from arbitrary points at any time later,  without keeping the whole thing in memory.</p>

<p>Is this possible?</p>

<p>I want to open a handle to a file, nothing else will be reading/writing to this file, and be able to grab data from any given offset &amp; length at a point later, without searching the disk for the file again.</p>

<p>I had assumed there would be some sort of</p>

<pre><code>1, open handle to file
2, create reader
3, skip reader to X
4, read for Y
5, reset reader to 0
6, return to step 3
</code></pre>

<p>At first it seemed like <code>BufferedReader.mark</code> would be what I'm after, but the docs suggest that if I <code>mark, skip, read, reset</code> the contents from where I marked, to where I skipped, would be kept in memory?</p>

<p>From the docs, </p>

<blockquote>
  <p>Limit on the number of characters that may be read while still
  preserving the mark. An attempt to reset the stream after reading
  characters up to this limit or beyond may fail. A limit value larger
  than the size of the input buffer will cause a new buffer to be
  allocated whose size is no smaller than limit. Therefore large values
  should be used with care.</p>
</blockquote>

<p>It says "read", so perhaps if I skip, it doesn't count towards this limit (that makes sense), but I might be reading quite a bit, so it seems this newly allocated input buffer could get pretty large. I don't want that to happen...</p>

<p>Is there a better way to be going about this?</p>
