• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting ZipOutputStream to byte[] or ByteArrayOutputStream

 
ten jones
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having the worst time figuring this out and I haven't found a solution close to what I need anywhere online.

We are using EJB, 11g and ADF to create a system where the user can download an xml file and all images pertaining to the xml file in one, clean zip package by clicking a button/link. The download must appear as a standard "Open, Save, Cancel" user prompt ( CUSTOMERS REQUEST)

I created the xml, I can pull the images from the SQL DB and I believe they are being input into my instance of ZipOutputStream, but the problem is returning the ZipOutputStream. The system plays friendly returning ByteArrayOutputStream pdfs, docs and images so I wanted to return the zip file the same way.

With our faces-config.xml, I cannot return values exactly how I need to. I have to go through response and context.


Below is where the files are pulled and stored in the ZipOutputStream...



And this is where it is returned as a request...


Note where the bytearray needs to be. Is this possible?
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand why you are writing your zipped data to a FileOutputStream. That isn't what you want. And I don't understand why you ask how to write your zipped data to a byte array, either, because that isn't what you want. You want to write your zipped data to the response's output stream, don't you? If that's what you are saying, then just do this:
 
ten jones
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not understanding that solution. I need the. exact inverse of that.
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know what you mean by "the exact inverse of that".

What I posted sends the zipped data to the response's output stream. I can't imagine what an "exact inverse" of that process would be. But anyway, your response suggests that you didn't want to send the zipped data to the response's output stream. I was under the impression that was your requirement.

But apparently it isn't. So how about a description of your requirement? What do you propose to do with that zipped data?
 
Wim Folkerts
Greenhorn
Posts: 19
Java jQuery Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The requirements are indeed not very clear. I assume Ten Jones wants to return the zipoutputstream. Doing this you may want to use the ServletOutputStream. See below a quick example


Hope this helps,
Wim
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic