| Author |
InputStream duplication, how to ?
|
Srinu Nanduri
Ranch Hand
Joined: Mar 20, 2006
Posts: 42
|
|
Hi I have a problem with InputStream (FilterInputStream) in my application. I would like to start with reminding the point that "Once an input stream is read, we cannot read it again". Any comments ? Now, my question is, Is there any possibility to duplicate the input stream i have such that i can use the original / duplicate and pass the other one as it is further to my application. I will be very thankful if some one can help me with this. Thanks & Regards, Srinivasan.
|
SCJP, SCWCD
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8265
|
|
|
InputStream and Reader both have a reset() method which can be used to rewind a stream to a point identified with a call to mark(). These method are not supported with all streams/readers and care must be used in setting the size of data preserved with the mark() call.
|
"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12271
|
|
You could read the InputStream completely to a byte[] and construct any number of streams from that source with ByteArrayInputStream. (Assuming the total is reasonable to keep in memory) Bill
|
Java Resources at www.wbrogden.com
|
 |
 |
|
|
subject: InputStream duplication, how to ?
|
|
|