• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Converting ZipOutputStream to byte[] or ByteArrayOutputStream

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not understanding that solution. I need the. exact inverse of that.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 19
jQuery Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I brought this back from the farm where they grow the tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic