• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

How do i copy a input stream !

 
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Sheriff
Posts: 22696
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
It's a pleasure to see superheros taking such an interest in science. And this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic