Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting data from an outputstream

 
mainasiris
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a requirement where I cannot write the read data to a file simultaneously.
Is there a way where I can write the bytes read from servlet input stream to an output stream ( note : not to a file ) temporarily ; and then use the data conatined in this outputstream to write a file?
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"mainasiris"
Please review the JavaRanch Naming Policy then edit your profile so that your publicly displayed name complies with the rules.
Thanks for your cooperation.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way where I can write the bytes read from servlet input stream to an output stream ( note : not to a file ) temporarily ; and then use the data conatined in this outputstream to write a file?
What's wrong with writing it to a file in the first place? FileOutputStream and FileWriter work great for this. If you really need to avoid a file for some unknown reason, you could use something like a ByteArrayOutputStream or a CharArrayWriter to store the data in memory first, and later read the array and write a file. But offhand I can't imagine a reason why this would be useful or necessary, so maybe I'm missing something about your requirements.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic