简体   繁体   中英

java text file set line reader

I want to set line reader to first position , for example It just finished the reading whole text file and I want to set line reader to the position when it first started to read text file ?

I opened txt file using scanner

Is it possible?

Scanner itself has no way to rewind the input. You might be able to reset() the underlying input stream, but that might not be supported depending on what stream implementation is being used. Your best bet is to close and reopen the input.

EDIT:

If you cannot close/reopen the input, then try calling reset() on the underlying stream.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM