0

Hi All,

Im generating some output files(kind of reports) in my reportGenerator class.Acutally im creating then into hard disk and showing them in browser. But i want this scenario to be developed into my project :
Want to return the generated file as stream to another class, and show that file into broswer with out creating that file anywhr in the hard disk.

Your help is much appreciated.
Thanks in Advance,
Shanti.

2
Contributors
1
Reply
9
Views
4 Years
Discussion Span
Last Post by JamesCherrill
0

One way is to write the generated data to a PipedOutputStream that's connected to a PipedInputStream in the other class. This is a very good solution, provided you are happy to mauintain two threads (one writing, one reading).
A simpler approach is to write the data to a ByteArrayOutputStream, which just stores it in a byte[] in memory, then the second class can read that byte[] via a ByteArrayInputStream.
Details of all four of those classes in is the usual Java API documentation

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.