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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.