How to move inputStream back to the first line?



Hi,

I have an inputStream to read a text file:

BufferedReader inputStream = new BufferedReader(new FileReader(fileName));
String line = inputStream.readLine();

After reading several lines, I hope to bring inputStream back to the first line. How can I do it?

Right now, I do:

inputStream.close();
BufferedReader inputStream = new BufferedReader(new FileReader(fileName)); //start over again. I feel it is a dumb way.

Thank you.
.



Relevant Pages

  • Re: How to move inputStream back to the first line?
    ... String line = inputStream.readLine; ... After reading several lines, I hope to bring inputStream back to the first line. ... BufferedReader inputStream = new BufferedReader); ... The Lumber Cartel, local 42 (Canadian branch) ...
    (comp.lang.java.programmer)
  • Re: How to move inputStream back to the first line?
    ... BufferedReader inputStream = new BufferedReader); ... After reading several lines, I hope to bring inputStream back to the ... One way could be to use mark() to mark the beginning of the file, ... I do not think you can call reset after closing the stream though. ...
    (comp.lang.java.programmer)