title: Problems on Mac with java.util.zip.* (Extraction)
body: <p>I made a program and I created an export function for documents (entries).
  The procedure: The user has favorited documents. There exist 2-3 strategies
  (BibTex,RIS,HTML) a user can choose to export his documents.
  For each strategy a new .zip file is being generated with all documents inside.
  The created .zip archives are sent to the user via email.</p>
  
  <p>For me ( Windows ) it works great. I can extract those archives without any problems.
  But a friend of my, who is using Mac, gets errors while extracting them and I do not know why.</p>
  
  <p>Here the important code:</p>
  
  <pre><code>for ( String strategy : strategies ) {
  // Coderedundanz
  // Jede Strategie benötigt eigene Parameter
  if (strategy.equals("BibTex")) {
      _zipName = "ezdl_export_bibtex";
      _fileExtension = ".bib";
      _strategy = csf.bibTex;
  }
  else if (strategy.equals("RIS")) {
      _zipName = "ezdl_export_ris";
      _fileExtension = ".ris";
      _strategy = csf.ris;
  }
  else if (strategy.equals("HTML")) {
      _zipName = "ezdl_export_html";
      _fileExtension = ".html";
      _strategy = csf.html;
  }
  else {
      _zipName = _zipExtension = "";
      _fileExtension = "";
      _strategy = null;
  }
  
  // Gibt es eine korrekte Strategie?
  if ( !_zipName.equals("") &amp;&amp; !_fileExtension.equals("") &amp;&amp; _strategy != null) {
      // 1. .zip Datei generieren
      // 2. Für jedes TextDocument eine eigene Datei erstellen
      // 3. Datei in die .zip Datei einfügen
      // 4. .zip Datei schließen und in die E-Mail hinzufügen
      File file = File.createTempFile(_zipName + _zipExtension, ".tmp");
      ZipOutputStream out = new ZipOutputStream(new FileOutputStream(file));
      out.setLevel(6);
      for ( TextDocument document : documents ) {
          out.putNextEntry(new ZipEntry( document.getOid() + _fileExtension));
  
          String temp = _strategy.print ( (TextDocument) document).asString().toString();
  
          out.write( temp.getBytes() );
          out.closeEntry();
      }
  
      out.finish();
      out.close();
  
      PreencodedMimeBodyPart part_x = new PreencodedMimeBodyPart("base64");
      part_x.setFileName(_zipName + _zipExtension);
      part_x.setContent(new String(Base64Coder.encode( getBytesFromFile (file))), "text/plain");
      multi.addBodyPart(part_x);
  
      if (file.exists())
          file.delete();
  </code></pre>
  
  <p>You see for each strategy an own archive is being created.
  The program loops through the documents (TextDocument)
  and with _strategy.print you get a String as output.</p>
  
  <p>As I said.. for me it works great, but not on Mac.
  Are there any differences? I guess.. .zip is .zip.
  Or should I create tarballs (.tar.gz) for Mac?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <pre>
  serena:tmp3 alex$ unzip ezdl_export_bibtex.zip 
  Archive:  ezdl_export_bibtex.zip
    End-of-central-directory signature not found.  Either this file is not
    a zipfile, or it constitutes one disk of a multi-part archive.  In the
    latter case the central directory and zipfile comment will be found on
    the last disk(s) of this archive.
  note:  ezdl_export_bibtex.zip may be a plain executable, not an archive
  unzip:  cannot find zipfile directory in one of ezdl_export_bibtex.zip or
          ezdl_export_bibtex.zip.zip, and cannot find 
  </pre>
  
  <p>Here is a screen: <a href="http://img3.imageshack.us/i/ziperror.png" rel="nofollow">http://img3.imageshack.us/i/ziperror.png</a>. It shows the error: "Unable to unarchive - Error - 1 - Operation not permitted"</p>
  
  <p>I also changed my code to:</p>
  
  <pre><code>out.write( temp.getBytes() );
  out.flush();
  out.closeEntry();
  </code></pre>
  
  <p>But still the same problem.</p>