This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes Streaming out data using ServletOutputStream Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Streaming out data using ServletOutputStream" Watch "Streaming out data using ServletOutputStream" New topic
Author

Streaming out data using ServletOutputStream

Sara Tracy
Ranch Hand

Joined: Jan 06, 2006
Posts: 45
hi !

I'm using the following snippet to read a file contents (data.txt) and stream out through ServletOutputStream.



However, when the file is encrypted, I would like to decrypt it, and then stream it out via ServletOutputStream. I call an encryption program that decrypts the file (dataenc.txt) and returns the data as a byte array. How do I use this byte array with ServletOutputStream ?

I tried using the below code, but nothing is returned.


Can anybody tell me what's wrong in the code ? thanks.
Sara
[ August 09, 2006: Message edited by: Sara James ]
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8913
    
    8

You should flush and close your output stream in both cases. You don't need the intermediate ByteArrayInputStream, either:


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Sara Tracy
Ranch Hand

Joined: Jan 06, 2006
Posts: 45
I have included close() and flush(). I also got rid of the extra ByteArrayInputStream, but still the file contents aren't displayed.
There is no error as well, not sure where the problem is. Thanks.

Sara
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8913
    
    8

Have you made sure that decrypt is doing it's thing right? Printing out the output on the server side?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Streaming out data using ServletOutputStream