 <p>You must call reader.mark() <em>before</em> the first while loop; reader.mark() essentially saves the current position of the reader so that you can go back to that position when you call reader.reset().</p> <p>You will also not want to pass in 0 to reader.mark(). See the java spec for the parameter below:</p> <p>readAheadLimit - 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> <p>(In other words, passing in 0 will be useless. You need to pass in a number larger than the number of characters read in between mark() and reset()).</p>