Layered IO Streams (ZipOutputStream)

Hi all,
I've been trying to get some layered streaming going.
Zip File (created on the fly) + Other Files -> Jar archive
Getting everything into a jar archive is ok, but I'd like to be able to create the zip file on the fly without having to make a temporary file elsewhere. But I run into problems signing off the streams. If I set some streams up simply as follows:
ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream( new
FileOutputStream(new File("out/output.jar"))));
zos.putNextEntry(new ZipEntry("demo1.zip"));
ZipOutputStream zps = new ZipOutputStream(zos);
zps.putNextEntry(new ZipEntry("readme1.txt"));
zps.flush();
zps.closeEntry();
zps.close();
zos.closeEntry();
zos.putNextEntry(new ZipEntry("demo2.zip"));
zos.close();
This snippet doesn't actually read or write anything, but still triggers the error. I get a stream closed error when it hits zos.closeEntry(). I'm guessing this is because zps.close() closes down everything, including its underlying streams.
Problems is though, if I dont use zps.close() it doesn't sign off the zip file correctly. I end up with an End-of-central-signature directory not found error when I try to open the zip file that has been created.
Got pretty stumped on this. Anyone tried layering ZipOutputStreams like this successfully?
Cheers.

oh damn I feel like a buffoon! Spent hours looking at that and I don't know how many times I looked up the ZipOutputStream in the javadocs and didn't see the finish method.
Thanks for the reply.
DJ.

Similar Messages

  • Compressing streams

    i can make a file transfer program, but I can't figure out how to compress the stream, could someone explain how to use the java.util.zip package

    If you have a Stream you just wrap a Zip Stream around it to compress or decompress:
    byte[] myData = . . . // your data, from somewhere
    OutputStream os = . . . // your uncompressed output stream
    ZipOutputStream zos = new ZipOutputStream( os );
    zos.write( myData ); // sends compressed data!If you want to read/write .ZIP files, be sure that your read or write a ZipEntry at the start of each logical file (zipped file within the .ZIP file).

  • File (Directory) object problem?

    Hi there. My problem is as follows. The method below is supposed to access an pre-existing directory with five previously saved test files, read in those files as account objects, add the objects to an ArrayList, then return the ArrayList. It seems to be able to create a file object representing the directory alright but it then insists that there are no files in the directory! Have I fouled up or is there some subtlety that I'm unware of? I was wondering if the fact that the account files have a .bac extenstion had something to do with it.
    Here's the method, with the two lines of code where I think the problem might lie in bold print:
    public ArrayList retrieveAccounts()throws IOException{
    ArrayList accounts = new ArrayList();
    File accDir = new File("C:" + File.separator + "accounts"); //creates a directory object
    //The following S.o.p statements are for test and maintenance purposes rather than user feedback
    System.out.println("Directory " + accDir.getCanonicalPath() + " opened");
    System.out.println("Confirm Accounts directory exists: " + accDir.exists());
    System.out.println("Directory: " + accDir.isDirectory());
    String [] accFiles = accDir.list(); //gets a list of files in the directory and saves it as a String array
    System.out.println("Number of files in directory: " + accDir.length());
    while(i < accDir.length()){
    filename = accFiles;
    try{
    //open layered input Streams to access the next account file in line
    ObjectInputStream in = new ObjectInputStream(new FileInputStream("C:"+ File.separator + "accounts" + File.separator + filename));
    account = (Account)in.readObject();
    accounts.add(account);
    in.close(); //closes Streams for that particular file
    }catch(IOException e){System.out.println("Filing error as follows: " + e);
                }catch(ClassNotFoundException e){System.out.println("Class not Found. Details: " + e); }
    filename = null; //frees up reference for next file
    i++;//counter increments by one
    return accounts;

    This is what I was trying to do minus the comments and maintence and test code:
    public ArrayList retrieveAccounts()throws IOException{
    ArrayList accounts = new ArrayList();
    File accDir = new File("C:" + File.separator + "accounts");
    String [] accFiles = accDir.list();
    while(i < accDir.length()){
    filename = accFiles;
    try{
    ObjectInputStream in = new ObjectInputStream(new FileInputStream("C:"+ File.separator + "accounts" + File.separator + filename));
    account = (Account)in.readObject();
    accounts.add(account);
    in.close();
    }catch(IOException e){System.out.println("Filing error as follows: " + e);
    }catch(ClassNotFoundException e){System.out.println("Class not Found. Details: " + e); }
    filename = null;
    i++;
    return accounts;
    By the way, your the first Java programmer that I've met that doesn't like comments! :)
    NOTE: Think I may have spotted where I went wrong in my code.
    filename = accFiles;
    Forgot to point it at the specific element of the array, like so:
    filename = accFiles[i];
    Thanks for your help!

  • File Compression Using ByteArrayInput/OutputStream

    Hi,
    I want to write a File compression program using ByteArrayInput/OutputStream. It should access multiple files and zip the contents of the files and give it in the ByteArrayOutputStream so the user can name that file and store it as zip. How to do this. I have done this with OutputStream. I want the code its very urgent!

    u can use this code to compress and zipping the files
    import java.util.zip.*;
    public class Compress
    public static void doit(String filein[], String filepath[], String fileout)
    // Common Input streams for all the files that will be zipped
    FileInputStream fis = null;
    // Output stream for the ZIP file
    FileOutputStream fos = null;
    try
    fos = new FileOutputStream(fileout);
    // Initialize Zip output stream
    ZipOutputStream zos = new ZipOutputStream(fos);
    // Add entries to the ZIP file
    ZipEntry ze = null;
    // Initialize buffer for the output data
    final int BUFSIZ = 4096;
    byte inbuf[] = new byte[BUFSIZ];
    int n;
    for ( int i = 0; i < filein.length; i++)
    fis = new FileInputStream(filein);
    // Add entries into the ZIP file and give it the display name.
    // Upon unzip the same directory structure as given in the filepath will be followed
    // The file path is the complete path of the file including the file name.
    ze = new ZipEntry(filepath[i]);
    zos.putNextEntry(ze);
    inbuf = new byte[BUFSIZ];
    // write output to the out put stream
    while ((n = fis.read(inbuf)) != -1)
    zos.write(inbuf, 0, n);
    fis.close();
    fis = null;
    zos.close();
    fos = null;
    catch (IOException e)
         System.err.println(e);
    finally
         try
              if (fis != null)
                   fis.close();
         if (fos != null)
         fos.close();
    catch (IOException e)
         System.err.println("\nError Occured while Zipping the files: " + e.getMessage());
    public static void main(String args[])
    // Files to be Zipped
    String filein[] = {"file1.txt", "file2.txt", "file3.txt",};
              // Display name that appears in Win ZIP or any other unzip utility
              String filepath[] = {"temp\\file1.txt", "temp\\file2.txt", "temp\\file3.txt",};
    // Name of the Zip file
    String fileout = "compress.zip";
    // Zip it
    doit(filein, filepath, fileout);

  • Controlling streaming different layers

    I have a banner that has 2 parts. The text and background
    moves in first. The clouds are supposed to move through next and
    keep streaming indefinitely while the background stays put. How can
    I achieve this?

    micheljon,
    > The clouds are supposed to move through next and keep
    > streaming indefinitely while the background stays put.
    How
    > can I achieve this?
    Put your clouds into a movie clip symbol. Movie clips'
    timelines run
    independently from the timelines in which they sit.
    \David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • Help:  unable to open files created with ZipOutputStream

    I am seeing some weird behavior with ZipOutputStream, using JDK 1.3.1_01 on Win2K. The code that follows is a snippet from a servlet that delivers a ZIP archive of a set an entire directory tree. I was preparing to roll it into production, but one of my testers noticed a bug that I didn't see.
    It seems that her version of WinZip (6.x) was unable to properly extract the files from the archive while mine (8.0) had no problems. I then tried a couple of other programs, and I've been able to reproduce the behavior with the built-in viewer in Lotus Notes 5 (the only other utility I had handy).
    I've made sure to call closeEntry() on each ZipEntry, and to call finish() before close() on the ZipOutputStream itself. Has anyone seen this behavior besides me?
    Thanks and regards,
    Casey
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
        response.setContentType("application/zip");
        response.setHeader("Content-Disposition","attachment; filename=\"package.zip\"");
        File dir = new File(m_templateDir);
        ZipOutputStream out = new ZipOutputStream(response.getOutputStream());
        addFilesToPackage(dir, "", out);
        out.finish();
        out.close();
    // Recursively walks the directory, adds files to the output stream,
    // and calls itself to handle sub-directories
    private void addFilesToPackage(File dir, String pathPrefix, ZipOutputStream out)
    throws IOException {
        File[] list = dir.listFiles();
        for (int k=0; k<list.length; k++) {
            File f = list[k];
            if (f.isDirectory()) {
                addFilesToPackage(f, pathPrefix + f.getName() + "/", out);
            } else {
                ZipEntry ze = new ZipEntry(pathPrefix + f.getName());
                out.putNextEntry(ze);
                InputStream in new FileInputStream(f);
                byte[] buff = new byte[2056];
                int bytesRead = 0;
                while((bytesRead = in.read(buff)) > -1) {
                    out.write(buff, 0, bytesRead);
                out.closeEntry();
                in.close();
    }

    I had also a problem with W2K when using ZipInputStream, I could not to solve it.
    so I used Unpacked Streams.
    weird indeed.
    Sometimes it works just fine.
    FileInputStream fis;
    byte [] in;
    //ZipFile zf = new ZipFile(new File("data/products.zip"));
    //ZipEntry ze = zf.getEntry("products.wsl");
    //fis =new BufferedInputStream( zf.getInputStrea(ze));
    fis = new FileInputStream("data/products.wsl");
    koko = fis.available();
    in = new byte[koko];
    fis.read(in);
    fis.close();
    I think code was something like abowe (there has been a while...)

  • Can a file be sent in TCP as a stream?

    I am trying to implement a simple file transfer operation using TCP/IP sockets. I have found information about sending streams, but not packets. Is it possible to send files as streams? or even better, how do i implement sending packets using TCP/IP?

    I am trying to implement a simple file transfer
    operation using TCP/IP sockets. I have found
    information about sending streams, but not packets. Is
    it possible to send files as streams? or even better,
    how do i implement sending packets using TCP/IP?TCP/IP has a layered design so you don't have to worry about the detail. When you use a stream, the data written to it (transparently to you) divided into packets, sent across the network and reassembled at the other end.
    Good eh?
    You need to read up on how to create a Socket and write data into its output stream.
    And for the other end of the connection how to have a ServerSocket listening for such connections and doing something with data when it is received.

  • .pdf files created in Photoshop - Not all layers appear in Connect

    So I have created a marketing flyer in Photoshop that contains images and text.  I save this out as a .pdf file and upload to Connect.  When I open the file, many of the layers, usually the text layers, are missing.  I've tried saving the original Photoshop file a number of different ways, like flattening, etc, and the .pdf file a lot of different ways.  But it still appears in Connect missing some of the text layers.  BTW, the original .pdf file is fine.

    Understand that not all Adobe PDF features will translate completely in an Adobe Connect meeting if using the Share Document pod.
    When you upload a Powerpoint or PDF file using that pod, the document is converted on the fly to Adobe Flash format so it can be streamed very efficiently. Not all features in Powerpoint and PDF files will convert to an equivalent look and feel when converted.  If you see inconsistencies, then try using a different font or font size. Some features just won't translate. Of course as new versions of Adobe Flash are released then more features will convert. So, beware that if you must have a document look exactly as it does in the native application you always have the option of screen sharing where no conversion takes place. Just beware when you use screen sharing you are using a lot more network bandwidth. It's a trade off but you do have a choice!

  • Streaming Audio repeats every 11.5 minutes????

    when on the CBC Ideas streaming audio site, the stream repeats and layers over itself after 10-15 minutes.
    try it...
    Im on a older computer on ubuntu 10.04 (768 megs ram)

    Check to see if the problem is happening at the 99th slide. iDVD slideshows can hang up there. If so, reduce to 98.
    I make my slideshows in iPhoto instead of iDVD, then File/Export to my desktop and drag the resulting Quicktime movie into the edge of the iDVD project's main window. You won't have the glitch at No. 99, if that's the problem.

  • Safari will  not play streaming video or audio

    Hi everyone,
    I have had my iBook for a year and never even tried to take advantage of streaming video or audio b/c I had a dial-up connetion until very recently. Now that I have a high speed connection I would like to watch trailers and listen to music on myspace. I cannot watch trailers at www.apple.com/trailers/ or any video on myspace.com. Nor can I listen to music (I think they are xml files) on myspace.com. I'm currently running on Mac OSX 10.3.9 and Safari 1.3.1. Any help would be appreciated. Thanks in advance.
    Christopher

    Hi
    Well I have the opposite effect here - the video plays fine on my MBP, yet not on my Intel iMac. On the iMac the video panel never appears. Rather tells me it needs Flash.
    Safari is the same on both systems (or at least that's what I think). No plugin blocks are present. To test if the Preference files might be causing the problem, On the iMac, I moved to the desktop from the Macromedia folder in ~/Library/Preferences folder the folder inside the SharedObjects folder. Restarted the system/Safari but the video still does not play.
    In the past, Layers magazine has not been a problem, however, I haven't viewed one for several months. Given what others have posted, there seems to be an oddity here that is not machine or Safari specific. I'll have to investigate more when I have time tomorrow.
    Try the Video from another user account. See if this is system-wide, or just specific to your user account. BTW, video played fine on the iMac in Firefox.

  • Streaming with on2 VP6  8 bit alpha canne

    I need to send a live streaming to Adobe Flash Media Server  encoded with on2 VP6  8 bit alpha cannel (chroma key) so all clients see only the speaker with no background.
    what hardware or software support realtime encode VP6 alpha channel  ?
    thanks

    Ooppp, got mixed up with chroma-keying... sorry 'bout that.
    So what have you tried? have you attempted to stream video with alpha channel to the server? what happened? How are you displaying the video at the other end?
    Is it on a Web page? are you using wmode=transparent as a <param> on the vido player? so that the player itself becomes invisible?
    Here is an example of a VP6 video with alpha played over the top of a video page (the walk on):
    http://www.mrfilmbiz.com/
    This is not a live stream but a progressive downloaded video, but I don't think it would matter. The thing that let's you see that the alpha channel is there (because the player is invisible) is using the wmode=transparent. Of course you may need a custom Flash player like the one used in the example above... it uses NetStream rather than the FLVPlayback component... I'm not sure if you can make the component disappear like that.
    For review:
    Window Mode (wmode) - What's It For?
    There are three window modes.
    Window
    Opaque
    Transparent
    By default, the Flash Player gets its own hWnd in Windows. This means that the Flash movie actually exists in a display instance within Windows that lives above the core browser display window. So though it appears to be in the browser window, technically, it isn't. It is most efficient for Flash to draw this way and this is the fastest, most efficient rendering mode. However, it is drawing independently of the browser's HTML rendering surface. This is why this default mode (which is equivalent to wmode="window") doesn't allow proper compositing with DHTML layers. This is why your JavaScripted drop-down menus will drop behind your Flash movie.
    In windowless modes (like opaque), Flash Player doesn't have a hWnd. This means that the browser tells the Flash Player when and where to draw onto the browser's own rendering surface. The Flash movie is no longer being rendered on a higher level if you will. It's right there in the page with the rest of the page elements. The Flash buffer is simply drawn into whatever rectangle the browser says, with any Flash stage space not occupied by objects receiving the movie's background color.
    Hope this help a little.
    Best of luck,
    Adninjastrator

  • Using Photoshop files with layers in iDVD

    I prefer using my old DVD Studio Pro to iDVD, but since newer versions of Quicktime can't export to mpeg2 I'm forced to either use iDVD or buy a new version of DVDSP. Given that iDVD is already on my computer and DVDSP requires the purchase of the Final Cut Suite, I was wondering about how tweakable the menus and themes in iDVD are. Is there a way to create customized themes with your own menu pages with different shaped buttons, unique images and text? In DVDSP you could import Photoshop files and the file would retain the layers which would allow you to use layers as buttons, images, or text on you menu. Is there a way to do this in iDVD or am I out of luck? Thanks in advance!

    any version of DVDSP contained "Compressor", which does the conversion of any iM project into the needed m2a, m2v streams for use in DVDSP... and no version of QT was able to export to mpeg2, except you tought that trick with some plug-ins, installed by DVDSP.... (?)
    sure, you can customize menus, but not as flexibile as DVDSP; read the tutorials, or one of the "Missing Manuals" by David Pogue; import of PS-layers is not supported; iDVD is a consumer product.-

  • How can I get the position stream for a composition?

    I am writing an AEGP plugin for AfterFx and I need to get the position stream for a composition. I have based my plugin on ProjDumper.
    Can anyone help?

    Hi Shachar,
    Many thanks, that goes some way to explain it.
    However I am creating a composition adding text layers to it and animating the positions of the individual text layers. Then I create a second composition and include the first as a nested composition and I animate the position of the first composition within the second composition.
    When I run my plugin I only see the animations I added to the individual text layers, they are not combined with the overall animation attached to the first compisition within the second composition.  The animation data for the first composition must be stored somewhere. Do you know where ?
    I have been looking at source items and markers neither seem to provide the information I am interested in. Any clues would be very helpful.
    Thanks in advance.

  • Problem with the streams....

    Dear All,
    I am trying to zip a file in the client side and sending it to the server side machine......there, i am trying to unzip it and writting it over there...for this, i am using a seperate program in the client side and in the server side.................................
    In the client program, after opening all the necessary streams and all formalities, i am using the code...
    "InputStream in = urlconnection.getInputStream();
    while (in.read()!=-1);"
    only if i use the above code, the zipped file is transfered to my server machine...but in this case, the link with the server is not getting disconnected...i mean the command prompt remains alive, without stopping...what i inferred is, my control is got into the above said "InputStream in = urlconnection.getInputStream();"...indefinitely...
    so i tried of removing the above said statement.....in this case, the zipped file is NOT getting written in my server machine....
    what to do???
    any suggestions please...waiting for the reply very anxiously, refreshing this site for every 2 minutes....
    sakthivel s.
    snippet code for ur reference...
    Client side
    try
    ZipOutputStream zipoutputstream = new ZipOutputStream(urlconnection.getOutputStream());
    ZipEntry zipentry = new ZipEntry(filename);
    zipentry.setMethod(ZipEntry.DEFLATED);
    zipoutputstream.putNextEntry(zipentry);
    byte bytearray[] = new byte[1024];
    File file = new File(filenamedir);
    FileInputStream fileinputstream = new FileInputStream(file);
    BufferedInputStream bufferedinputstream = new BufferedInputStream(fileinputstream);
    int length = 0;
    while((length=bufferedinputstream.read(bytearray)) != -1)
    zipoutputstream.write(bytearray,0,length);
    fileinputstream.close();
    bufferedinputstream.close();
    zipoutputstream.flush();
    zipoutputstream.finish();
    zipoutputstream.closeEntry();
    zipoutputstream.close();
    InputStream in = urlconnection.getInputStream();
    while (in.read()!=-1); // the said while loop....................
    System.runFinalization();
    urlconnection.getInputStream().close();
    urlconnection.disconnect();
    the way of connecting witht the server : (just a snippet of the code)
    URL serverURL = new URL("http://192.168.10.55:8001/servlet/uploadservlet");
    HttpURLConnection.setFollowRedirects(true);
    urlconnection= (HttpURLConnection)serverURL.openConnection();
    urlconnection.setDoOutput(true);
    urlconnection.setRequestMethod("POST");
    urlconnection.setDoOutput(true);
    urlconnection.setDoInput(true);
    urlconnection.setUseCaches(false);
    urlconnection.setAllowUserInteraction(true);
    urlconnection.setRequestProperty("Cookie",cookie);
    urlconnection.connect();
    Server Side:
    javax.servlet.ServletInputStream servletinputstream = httpservletrequest.getInputStream();
    ZipInputStream zipinputstream = new ZipInputStream(servletinputstream);
    ZipEntry zipentry = null;
    String directory="c:\\test"; // the unzipped file should be written to this directory...
    try
    File file = new File(directory);
    if(!file.exists())
    file.mkdirs();
    catch(Exception exp)
    {System.out.println("I am from Server: " + exp);}
    try
    zipentry = zipinputstream.getNextEntry();
    if(zipentry != null)
    int slash = zipentry.getName().lastIndexOf(File.separator) + 1;
    String filename = zipentry.getName().substring(slash);
    File file1 = new File(directory + File.separator + filename);
    FileOutputStream fostream = new FileOutputStream(file1);
    BufferedOutputStream bufferedoutputstream = new BufferedOutputStream(fostream);
    byte abyte0[] = new byte[1024];
    for(int index = 0; (index = zipinputstream.read(abyte0)) > 0;)
    bufferedoutputstream.write(abyte0, 0, index);
    servletinputstream.close();
    bufferedoutputstream.flush();
    bufferedoutputstream.close();
    zipinputstream.closeEntry();
    zipinputstream.close();
    fostream.flush();
    fostream.close();
    catch(IOException ioexception)
    {System.out.println("IOException occured in the Server: " + ioexception);ioexception.printStackTrace();}
    P.S: I am not getting any error in the server side or cleint side...the only problem is, the command prompt(where i am running my cleint program) is getting standing indefinitely...i have to use control-c to come to the command prompt again...this is because of the while looop said in the client machine....if i remove it...the file is not gettting transfered...what to do????

    Some thoughts:
    1) please quote your code so it's readable (see http://forum.java.sun.com/faq.jsp#messageformat ).
    2) why are you calling "System.runFinalization();"?
    3) Offhand I don't see where the read would ever stop. It's waiting for an end of input from the server, but the server doesn't even begin to write output to it. What happens when you connect to your server with a browser or some other client?
    4) is it really wise to read and write one byte at a time?

  • HELP -ZipOutputStream performance is not consistent across servers

    Hi,
    I have a pretty standard code that zips one folder in a zip file using ZipOutputStream. The folders that are zipped are 2 GB in size and consists of TIFF images files.
    We are currentinly in the testing phase and notice very inconsistent performance issues with the Zipping module. On the integration server, to zip 2 GB of data, the zip module took 5 minutes. However, when the same zip code runs on the staging server, it takes 20 minutes. Both the servers are the same in RAM capacity and processing powers. The size of the data is also the same: 20 GB.
    Can anyone help me understand what could be the issue such taht the performance is so detrimental when movingfrom one server to another.
    The only difference between the two servers is that on the integratoin server there is 20 GB of free harddisk space and on the staging server there is only 8 GB of hard disk space. Is it possible that because of the less disk space on staging, the OS itself is taking a few seconds extra on each write to allocate the space. Possibly disk fragmentation also may be a factor.
    For your reference, the zip code is as follows:
    public boolean createZip(File sourceToZip,String zipDestination, String zipFileName) throws IOException
               boolean result=false;
               try{
         // Check that the directory is a directory, and get its contents
         File d = sourceToZip;
         if (!d.isDirectory())
          throw new IllegalArgumentException("Not a directory:  "
              + sourceToZip);
         String[] entries = d.list();
         byte[] buffer = new byte[4096]; // Create a buffer for copying
         int bytesRead;
         ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipDestination+"/"+zipFileName));
         for (int i = 0; i < entries.length; i++) {
          File file = new File(d, entries);
         if (file.isDirectory())
         continue;//Ignore directory
         FileInputStream in = new FileInputStream(file); // Stream to read file
         ZipEntry entry = new ZipEntry(file.getName()); // Make a ZipEntry
         out.putNextEntry(entry); // Store entry
         while ((bytesRead = in.read(buffer)) != -1)
         out.write(buffer, 0, bytesRead);
         in.close();
         out.close();
         result=true;
              catch(IOException e)
                   throw e;
              return result;
         }If anyone has any ideas let me know Thanks.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    The free space could be an issue, but you can improve your code:
    ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipDestination+"/"+zipFileName));
    ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipDestination+"/"+zipFileName)));That will improve your performance considerably on all platforms. Also change your buffer of 4096 to 16k or 32k.
    You could also consider converting the TIFF files to JPEG instead of zipping them at all.

Maybe you are looking for