posted 17 years ago
A BufferedReader, by definition, reads more than it returns. It reads X amount of input all at once, then doles it out over time; that's what "buffering" means.
So here, X is some number greater than the length of your entire input. The first BufferedReader you create empties the whole StringReader out; the second one has nothing left to read.
You're right that the Javadoc for BufferedReader doesn't mention this, and it probably should. The rule is, really, that once you wrap a BufferedReader around a Reader, you can't read from that raw Reader ever again, because you don't know how much data the BufferedReader has read and not handed out yet.
You really have only one choice to write the kind of code you describe: refactor so that your topmost routine creates the BufferedReader, and everything else takes one as an argument. If the whole file is line-oriented, then this makes perfect sense.