From: Anabolik on 2 Dec 2009 03:25 How to return to the begin of InputStream after reading this file?
From: Lothar Kimmeringer on 2 Dec 2009 07:42 Anabolik wrote: > How to return to the begin of InputStream after reading this file? use a BufferedInputStream with mark and reset or just reopen the FileInputStream. If you need to access the file in a "random" (non-sequential) way, you can use RandomAccessFile http://java.sun.com/j2se/1.5.0/docs/api/java/io/RandomAccessFile.html and call seek(0) Regards, Lothar -- Lothar Kimmeringer E-Mail: spamfang(a)kimmeringer.de PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81) Always remember: The answer is forty-two, there can only be wrong questions!
From: Arne Vajhøj on 2 Dec 2009 21:37 Anabolik wrote: > How to return to the begin of InputStream after reading this file? Close and reopen the file. Arne
From: Arne Vajhøj on 2 Dec 2009 21:39 Lothar Kimmeringer wrote: > Anabolik wrote: >> How to return to the begin of InputStream after reading this file? > > use a BufferedInputStream with mark and reset or just reopen > the FileInputStream. If you need to access the file in a > "random" (non-sequential) way, you can use RandomAccessFile > http://java.sun.com/j2se/1.5.0/docs/api/java/io/RandomAccessFile.html > and call seek(0) I would not rely on mark reset. The docs for the marklimit method does not give a comfortable feeling. Arne
From: Lothar Kimmeringer on 3 Dec 2009 11:45 Arne Vajh�j wrote: > Lothar Kimmeringer wrote: >> Anabolik wrote: >>> How to return to the begin of InputStream after reading this file? >> >> use a BufferedInputStream with mark and reset [...] > > I would not rely on mark reset. > > The docs for the marklimit method does not give a comfortable > feeling. You need to specify the maximum number of bytes you want to be able to go back, that's the reason why I gave alternative ways to solve that. Regards, Lothar -- Lothar Kimmeringer E-Mail: spamfang(a)kimmeringer.de PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81) Always remember: The answer is forty-two, there can only be wrong questions!
|
Next
|
Last
Pages: 1 2 3 4 5 6 Prev: Forcing garbage collection Next: Problem tracking down an error |