title: BufferedReader: Determine byte offset of lines read
body: <p>I'm using a BufferedReader to read a byte stream (UTF-8 text) line by line. For a specific reason, I need to know where exactly in the byte stream the line starts.</p>
  
  <p>The problem: I can't use the position of the InputStream I plug into the BufferedReader as - well - the reader buffers and reads more than a line in one go.</p>
  
  <p>My question: <strong>How can I determine the precise byte offset of each line read?</strong></p>
  
  <p>One apparent (but incorrect) solution would be to use (line + "\n").getBytes("UTF-8").length. There is two problems with this approach: 1) Just to count the number of bytes, it's quite an overhead to convert the string back to bytes and 2) a newline is not always marked with "\n" - it might also be "\r\n", etc.</p>
  
  <p><strong>Is there any other solution to this?</strong></p>
  
  <p>EDIT: Every LineReader-like class I've seen so far seems to be buffered. Does anyone know of an unbuffered LineReader-like class?</p>