title: in java how to efficiently read x lines from a file, close it, and then open it again, starting at line x and continue reading
body: <p>BufferedReader has easy methods for reading a file line by line.  But there doesn't seem to be anyway to keep track of where you are, so you can get back to that place later.  FileInputStream has file getChannel() which returns a FileChannel which can tell you the current position in the stream.  So if you give a BufferedReader a FileInputStream to read from, you can find out where the BufferedReader stopped reading in the FileInputStream, and you can also set the FileInputStream to that position before you give it to the buffered reader.</p>
  
  <p>The problem is that the BufferedReader has read ahead in the file.  So the position of the FileInputStream is not the same as the position in the BufferedReader.  You may have read 20 lines from the BufferedReader, but the BufferedReader may have read 30 from the FileInputStream.  If later you reopen the file, based on the position in the FileInputStream, you will have missed those intervening 10 lines.</p>
  
  <p>I could reader character by character from the InputStream, but it seems like there is probably a better way...</p>