Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can I use an Inputstream twice?

807605Oct 16 2007 — edited Oct 17 2007
Hi,
I have to read a ServletInputStream more than one time. But how can I do this? I first tried to use mark() and reset() but that doesn't work. After that I tried to copy the InputStream into a byte[] with:
byte[] inByte = new byte[request.getContentLength()];
      InputStream sin = request.getInputStream();
      sin.read(inByte); 
...
InputStream in = new ByteArrayInputStream(inByte);
But if the InputStream of the request is too big, I could not read the whole stream (and the sin.available doesn't because its always 0).

Is there perhaps a class available where I can put my InputStream without parsing every single byte to a byte[] ?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 14 2007
Added on Oct 16 2007
8 comments
3,259 views