How to read arbitrary but continuous n lines from a huge file
<p>I would like to read arbitrary number of lines. The files are normal ascii text files for the moment (they may be UTF8/multibyte character files later)</p>

<p>So what I want is for a method to read a file for specific lines only (for example from 101-200) and while doing so it should not block any thing (ie same file can be read by another thread for 201-210 and it should not wait for the first reading operation.</p>

<p>In the case there are no lines to read it should gracefully return what ever it could read. The output of the methods could be a List</p>

<p>The solution I thought up so far was to read the entire file first to find number of lines as well as the byte positions of each new line character. Then use the RandomAccessFile to read bytes and convert them to lines. I have to convert the bytes to Strings (but that can be done after the reading is done). I would avoid the end of file exception for reading beyond file by proper book keeping. The solution is bit inefficient as it does go through the file twice, but the file size can be really big and we want to keep very little in the memory. </p>

<p>If there is a library for such thing that would work, but a simpler native java solution would be great.</p>

<p>As always I appreciate your clarification questions and I will edit this question as it goes.</p>
