aspose file tools
The moose likes Java in General and the fly likes How do i copy a input stream ! Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "How do i copy a input stream !" Watch "How do i copy a input stream !" New topic
Author

How do i copy a input stream !

Frank Jacobsen
Ranch Hand

Joined: May 17, 2002
Posts: 335
I have a senario, where i have to read the input stream first to make a md5 calculation, after this, i have to call a other program with the stream....

My problem is after tje md5 calculation, the stream is at the end.

I have tried to mark and reset the inputstream, but this is not supported.

How can i copy this stream fast and easy...


Frank

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

One option would be to calculate the MD5 sum while reading the contents, but if that's not possible then you have no choice but to store the contents in memory. The easiest way is to use a ByteArrayOutputStream to write to. Afterwards, you get the byte[] back from it and wrap it in a ByteArrayInputStream.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do i copy a input stream !
 
Similar Threads
Fastest way of calculating MD5
copying files
length of input stream
Fastest way of calculating MD5
Communicate between JSP and Servlet