Click to See Complete Forum and Search --> : reset the inputstream to read again


raghu123
05-11-2006, 06:51 AM
I need to read the text file.

In order to identify number of rows in text file.
I need to execute the while loop for first time.

if there less then 10 rows then i need to execute while again for reading content in each row.

With below code i am unable to execute second.
How to mark to first postion of stream for executing second while.

What is best way to do this

-------------------------------------------

if(stream!=null)
inReader = new BufferedReader(new InputStreamReader(inputStream ));
while ((strTemplateRow = inReader.readLine()) != null){ //first while
......
}

execution of while again

while ((strTemplateRow = inReader.readLine()) != null){ //second while
......
}

Cytael
05-15-2006, 12:25 AM
check out the API for BufferedReader:
http://java.sun.com/j2se/1.5.0/docs/api/java/io/BufferedReader.html

Looks like the mark and reset functions should serve you well.