Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #604
| Newsgroups | comp.lang.java.help |
|---|---|
| Subject | Using mark and reset on BufferReader, but with unknown file length |
| From | Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> |
| Organization | ULg |
| Date | 2011-04-23 13:24 +0200 |
| Message-ID | <87mxjhrz10.fsf@merciadriluca-station.MERCIADRILUCA> (permalink) |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, 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. 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: == readAheadLimit - Limit on the number of characters that may be read while still preserving the mark. After reading this many characters, attempting to reset the stream may fail. A limit value larger than the size of the input buffer will cause a new buffer to be allocated whose size is no smaller than limit. Therefore large values should be used with care. == Unfortunately, I don't know how much characters there will be in my file, and need to get to the beginning of it for reading it the second time. Could I use reset() without mark? And, as I can't type a big integer as readAheadLimit (because it would allocate too much memory), how can I do? Thanks. - -- Merciadri Luca See http://www.student.montefiore.ulg.ac.be/~merciadri/ - -- Failure is not falling down, you fail when you don't get back up. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/> iEYEARECAAYFAk2ytugACgkQM0LLzLt8Mhx2iwCfSVcmSXIl/siN17+HQAdJuvqy QwoAoK9CPuMy3SVDIiG+S2Acog4gUwOU =ple+ -----END PGP SIGNATURE-----
Back to comp.lang.java.help | Previous | Next — Next 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