Application Development and Automation Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
12,703 Views
1 Comment
0 Likes

In case you need to zip some data, for sending to the client on the fly without intermediary file creation that's simple as piece of cake:

ByteArrayOutputStream bos = new ByteArrayOutputStream(); 
                                                      ZipOutputStream zipfile = new ZipOutputStream(bos);
                                                      ZipEntry zipentry = new ZipEntry("packedFileName");
                                                      try {
                                                                zipfile.putNextEntry(zipentry);
                                                                zipfile.write("Zipped content".getBytes());
                                                                zipfile.close();
                                                      } catch(IOException e) {
                                                                e.printStackTrace();
                                                      }
byte[] result = bos.toByteArray();

Best wishes,

Max

1 Comment