Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #658
| From | Lothar Kimmeringer <news200709@kimmeringer.de> |
|---|---|
| Newsgroups | comp.lang.java.help |
| Subject | Re: Using mark and reset on BufferReader, but with unknown file length |
| Date | Tue, 26 Apr 2011 09:50:37 +0200 |
| Organization | Organization?! Only chaos here! |
| Lines | 39 |
| Message-ID | <4m204ajgp3vh.dlg@kimmeringer.de> (permalink) |
| References | <87mxjhrz10.fsf@merciadriluca-station.MERCIADRILUCA> |
| Reply-To | news@kimmeringer.de |
| NNTP-Posting-Host | mnch-5d86ee2d.pool.mediaways.net |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="us-ascii" |
| Content-Transfer-Encoding | 7bit |
| X-Trace | online.de 1303804238 8511 93.134.238.45 (26 Apr 2011 07:50:38 GMT) |
| X-Complaints-To | abuse@einsundeins.com |
| NNTP-Posting-Date | Tue, 26 Apr 2011 07:50:38 +0000 (UTC) |
| User-Agent | 40tude_Dialog/2.0.15.1de |
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.stben.net!border3.nntp.ams.giganews.com!nntp.giganews.com!ramfeed-1.ams.xsnews.nl!feed.xsnews.nl!border-3.ams.xsnews.nl!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!news.online.de!not-for-mail |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.help:658 |
Show key headers only | View raw
Hi,
Merciadri Luca wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
it's uncommon to sign news postings.
> For some reasons that come out of the scope of this discussion, I need
> to read a file twice. I would prefer not to do
>
> BufferedReader inputFile = new BufferedReader(new
> FileReader(inputFilename));
>
> twice, and, as a result, I would like to use my preceding
> BufferedReader to read the file again, a second time.
Why not using a RandomAccessFile instead?
> That is, I first read the file, then close it, then need to re-read
> it. To re-read it, I would like to use reset and mark methods, defined
> over BufferedReader objects. The problem is that mark obliges me to
> give a number of characters:
The reason is, that BufferedReader is creating an internal array
of that size to store the characters into. So setting it to the
size of the file you can also just read in the complete file in
an array for yourself and work on that so many times you want. If
the file is too big for the memory you have, you will run into
problems (of course).
Regards, Lothar
--
Lothar Kimmeringer E-Mail: spamfang@kimmeringer.de
PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)
Always remember: The answer is forty-two, there can only be wrong
questions!
Back to comp.lang.java.help | Previous | Next — Previous in thread | Find similar
Using mark and reset on BufferReader, but with unknown file length Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-23 13:24 +0200 Re: Using mark and reset on BufferReader, but with unknown file length Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-04-23 08:52 -0400 Re: Using mark and reset on BufferReader, but with unknown file length Lothar Kimmeringer <news200709@kimmeringer.de> - 2011-04-26 09:50 +0200
csiph-web