Note that there are some explanatory texts on larger screens.

plurals
  1. PODifferent ZipOutputStream results on different platforms
    primarykey
    data
    text
    <p>I have code that produces a zip output stream and then I send that stream through the response stream of a servlet. When testing in development on my mac everything works fine, however, when I put the code on my server (RHEL) the zip archive seems to be corrupt. When I try to list the contents of the file using jar I get:</p> <p>java.util.zip.ZipException: error in opening zip file</p> <p>But strangely, extracting the archive with jar works (other unarchivers fail, however).</p> <p>To test further, I made sure the contents of the zip file were exactly the same coming from my mac and RHEL. In both cases the size of the zip files were exactly the same, however, the hashes (MD5) were different.</p> <p>As I said, the code to produce the zip file as well as the contents are exactly the same so I have no idea what is going on. I'm fairly sure my zip file creation is correct since it is working on one of the platforms. There is no indication of any problem when generating the zip file on the RHEL server.</p> <p>Thoughts? Thanks for the help.</p> <p>EDIT: Here's the code ...</p> <pre><code>// first add the kml document ZipOutputStream stream = new ZipOutputStream(response.getOutputStream()); stream.putNextEntry(new ZipEntry("doc.kml")); stream.write(kml.getBytes(), 0, kml.length()); stream.closeEntry(); File image = null; byte[] bytes = null; FileInputStream fstream = null; // include the images for each type File images = new File("/tmp/images"); String filename = null; for(Type type: types) { filename = type.getName() + ".png"; image = new File(images, filename); bytes = new byte[(int)image.length()]; fstream = new FileInputStream(image); fstream.read(bytes); stream.putNextEntry(new ZipEntry(filename)); stream.write(bytes); stream.closeEntry(); fstream.close(); } stream.finish(); stream.flush(); stream.close(); </code></pre> <p>EDIT2: The plot thickens, it seems the RHEL zip stream is fine as long as there is only one image in the archive. Hopefully this is enough for google to help me out.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload