title: IOException: Size Mismatch on inflated file error
body: <p>In Android, I have a zip file i need to unzip, but while unzipping I end up getting a <em>IOException:  Size Mismatch on inflated file: 6843932 v 0</em></p>
  
  <p>I noticed when looking at the log i see a bunch of files unzipping.</p>
  
  <pre><code>geocoord/Canada/Nad27Nad83/123w53n3d.dac, 85472 bytes.
  Extracted 85472bytes.
  geocoord/Canada/Nad27Nad83/bc27v1_1.dac, 48032 bytes.
  Extracted 48032bytes.
  geocoord/Canada/Nad27Nad83/readme_Nad27ToNad83.txt, 646 bytes.
  Extracted 646bytes.
  geocoord/Canada/Nad83Csrs/readme_Nad83ToCsrs.txt, 593 bytes.
  Extracted 593bytes.
  geocoord/Canada/readme_canada.txt, 534 bytes.
  Extracted 534bytes.
  geocoord/coordsys.dty, 0 bytes.
  </code></pre>
  
  <p>And my code was just super simple:</p>
  
  <pre><code>private final int BYTE_SIZE = 4096;
  private void unzip( String src, String target )
    {
    try
          {
          zipFile = new ZipFile(src);
          Enumeration&lt;? extends ZipEntry&gt; entries = zipFile.entries();
          while (entries.hasMoreElements())
              {
              ZipEntry entry = entries.nextElement();
              File entryDestination = new File(target, entry.getName());
              if (entry.isDirectory())
                  entryDestination.mkdirs();
              else
                  {
                  entryDestination.getParentFile().mkdirs();
                  InputStream in = zipFile.getInputStream(entry);
                  OutputStream out = new FileOutputStream(entryDestination);
                  Log.i("log_me", entry.getName() + ", " + entry.getSize() + " bytes.");
                  int len = 0;
                  long count = 0;
                  byte[] arr = new byte[BYTE_SIZE];
                  while ((len = in.read(arr)) &gt; 0)
                      {
                      out.write(arr, 0, len);
                      count += len;
                      }
                  out.flush();
                  out.close();
                  in.close();
                  Log.i("log_me", "Extracted " + count + "bytes.");
                  }
              }
          } 
      catch (Exception e)
          {
          e.printStackTrace();
          } 
      finally
          {
          try
              {                                                
              if (zipFile != null)
                  zipFile.close();
              } 
          catch (Exception e)
              {
              e.printStackTrace();
              }
          }
      }
    }
  </code></pre>
  
  <p>So you can see it looks like it is doing it correctly.</p>
  
  <p>Is there anything anyone sees out of the ordinary?  I just unzipped the file, and it shows that the file:   geocoord/coordsy.dty has the following statistics.</p>
  
  <pre><code>Name          Size  Packed   Type        Modified     CRC32
   coordsys.dty  0     521,565  DTY File    7/9/2015     441587F9
  </code></pre>
  
  <p>Did something happen with the compression?  It seems like it might not have properly zipped those files.   (Another colleague wrote the zip)</p>
  
  <p>I was looking at his bash script for his zip and he wrote something like this:</p>
  
  <pre><code>ZipArgs= -r -9 
  @$(SrcRoot)bsitools\winx86\zip.exe $(ZipArgs) $(ZipTargetFile) $(ZipSourcePath) 
  </code></pre>
  
  <p>and when looking at the zip.exe file shows the commands as follows:</p>
  
  <pre><code>Copyright (C) 1990-1993 Mark Adler, Richard B. Wales, Jean-loup Gailly
  and Kai Uwe Rommel. Type 'zip -L' for the software License.
  
  Zip 2.0.1 (Sept 18th 1993). Usage:
  zip [-options] [-b path] [-t mmddyy] [-n suffixes] [zipfile list] [-xi list]
  The default action is to add or replace zipfile entries from list, which
  can include the special name - to compress standard input.
  If zipfile and list are omitted, zip compresses stdin to stdout.
  -f   freshen: only changed files  -u   update: only changed or new files
  -d   delete entries in zipfile    -m   move into zipfile (delete files)
  -k   simulate PKZIP made zipfile  -g   allow growing existing zipfile
  -r   recurse into directories     -j   junk (don't record) directory names
  -0   store only                   -l   convert LF to CR LF (-ll CR LF to LF)
  -1   compress faster              -9   compress better
  -q   quiet operation              -v   verbose operation
  -c   add one-line comments        -z   add zipfile comment
  -b   use "path" for temp file     -t   only do files after "mmddyy"
  -@   read names from stdin        -o   make zipfile as old as latest entry
  -x   exclude the following names  -i   include only the following names
  -F   fix zipfile (-FF try harder) -D   do not add directory entries
  -T   test zipfile integrity       -L   show software license
  -$   include volume label         -S   include system and hidden files
  -h   show this help               -n   don't compress these suffixes
  </code></pre>
  
  <p>I am thinking that  <code>-r -9</code> is not enough for his zip.  It seems that the file doesnt zip the files 1 level deep, but does all the other files correctly in subsequent directories.</p>
  
  <p><em>Edit:</em>
    I noticed that it printed out:</p>
  
  <pre><code>test of %My_Path%geocoord.zip FAILED
  
  zip error: Zip file invalid or insufficient memory (original files unmodified)
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>The files being zipped are SYMLINK files and folders.  It recursively walks those child folders just fine but the files themselves it is just copying the PTR, and not the actual data.</p>