Re: convenient way to read text file multiple times without reopening it
- From: "Mike Schilling" <mscottschilling@xxxxxxxxxxx>
- Date: Thu, 15 Nov 2007 05:39:33 GMT
"Tomas Mikula" <tomas.mikula@xxxxxxxxx> wrote in message
news:pan.2007.11.15.00.26.29.851166@xxxxxxxxxxxx
Hi,
I suppose that a convenient way to read text file is through FileReader.
But FileReader does not support the reset().
So, as a temporal remedy, I am opening the file twice:
Reader fr = new FileReader("filename");
.....
fr.close();
.....
fr = new FileReader("filename");
.....
Of course this is not a clean way. At least, the file could possibly be
removed or renamed by another program between the two calls to "new
FileReader()". So I want to open the file once and then read it
(sequentially) twice.
I suppose Java provides a convenient way for doing it, but I'm unable to
figure it out.
Thank you for pointing me the right way!
Can you read the whole thing into memory?
Alternatively, you can open it as a RandomAccessFile, which does allow you
to reset the file offset back to 0.
.
- References:
- convenient way to read text file multiple times without reopening it
- From: Tomas Mikula
- convenient way to read text file multiple times without reopening it
- Prev by Date: Re: Error opening file.
- Next by Date: Applets and HttpServer
- Previous by thread: Re: convenient way to read text file multiple times without reopening it
- Next by thread: Re: convenient way to read text file multiple times without reopening it
- Index(es):
Relevant Pages
|