title: Zipping and Unzipping Jar, It's not the same size!
body: <p>I'm making a modding application for a game. When I unzip and zip the same files: for some reason although it is open-able with 7Zip, it's not open-able in the actual application. Even though I've not edited the unzipped files - it's missing a few bytes. 
  I gathered the methods from the net and have been editing and retrying for the last 5 hours without success, any help guys? Thanks!</p>
  
  <p>Here's my code: </p>
  
  <pre><code>class zipper
  {
       static byte[] buffer = new byte[4096];
  
       public static void unzip(File zipfile, File outputfolder)  throws Exception
       {
           JarFile zip = new JarFile(zipfile);
  
           Enumeration entries = zip.entries();
           while(entries.hasMoreElements())
           {
               JarEntry entry = (JarEntry) entries.nextElement();
               File unzipped = new File(outputfolder,entry.getName());
  
               if (entry.isDirectory() &amp;&amp; !unzipped.exists())
               {
                   unzipped.mkdirs();
                   continue;
               }
               else if (!unzipped.getParentFile().exists())
                   unzipped.getParentFile().mkdirs();
  
               InputStream in = zip.getInputStream(entry);
               FileOutputStream fos = new FileOutputStream(unzipped);
  
               int count;
               while((count = in.read(buffer, 0, buffer.length)) != -1)
                   fos.write(buffer, 0, count);
  
               // clean up
               fos.close();
               in.close();
           }
     }
  
     public static void zip(File[] infiles, JarOutputStream jos) throws Exception
     {
         zip(infiles,"",jos);
  
         // clean up
         jos.flush();
         jos.close();
     }
  
     public static void zip(File[] infiles, String basefolder, JarOutputStream jos) throws Exception
     {
          FileInputStream fis = null;
         for(int i=0; i&lt;infiles.length; i++)
         {
             if(infiles[i].isDirectory())
             {
                 // recursive call for directories
                 zip(infiles[i].listFiles(), infiles[i].getName() + File.separator, jos);
                 continue;
             }
  
             String filepath = basefolder + infiles[i].getName();
             JarEntry entry = new JarEntry(filepath);
             jos.putNextEntry(entry);
  
             fis = new FileInputStream(infiles[i]); // get stream
  
             int count;
             while((count = fis.read(buffer, 0, buffer.length)) != -1)
                 jos.write(buffer, 0, count);
         }
     }
  }
  </code></pre>