readline() method of BufferedReader-another question

Sorry, I forgot to ask this in my first post.So, If I called readline() once, the readerwill be pointing to the next line (line 2). Now, if I want to go BACK to the beginning of the first line (line 1), which method can I use to do that?Thanks
[278 byte] By [lj75] at [2007-9-26 4:12:28]
# 1

Hi,

you can achieve this with mark() and reset() methods of BufferedReader. In mark(readAheadLimit) you should define the maximal amount of bytes which you want to "jump". Not every stream support this feature, so you have to check it first with markSupported() method.

Best regards,

Martin

edosoft at 2007-6-29 13:18:22 > top of Java-index,Archived Forums,Java Programming...
# 2

thanks =-)

Could this be another possible solution?

If I create another BufferedReader instance and call readline() method on the same file which contains those lines of record, does the reader automatically go back to the beginning of the first line?

(the readAheadLimit for my program would always change if I use mark(int) and reset()..therefore, i am looking for a possible alternative solution).

lj75 at 2007-6-29 13:18:22 > top of Java-index,Archived Forums,Java Programming...
# 3
Hi again,yes of course. If you want just to jump to the beginning of the file you may open a new stream (closing the first one prior).Cheers,Martin
edosoft at 2007-6-29 13:18:22 > top of Java-index,Archived Forums,Java Programming...