title: Issues with zipping files in Java
body: <p>I am currently trying to zip all files within a directory.</p>
  
  <p>The zip file is being created and the files are being processed - but for some reason the files are not appearing within the zip file.</p>
  
  <p>The code being used to complete this task is as follows:</p>
  
  <pre><code>public class FileZipper {
  
     public void zipDir( String dir, String zipFileName ) {
          try{
              File dirObj = new File(dir);
              ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFileName));
              Logger.info("Creating : " + zipFileName);
              addDir(dirObj, out);
              out.close();
          }
          catch (Exception e){
              Logger.error( e, "Error zipping directory" );
          }
    }
  
    private void addDir(File dirObj, ZipOutputStream out) throws IOException {
        File[] files;
        if( !dirObj.isDirectory() ){
            files = new File[] { dirObj };
        }
        else{
            files = dirObj.listFiles();
        }
        byte[] tmpBuf = new byte[1024];
  
        for (int i = 0; i &lt; files.length; i++) {
            if (files[i].isDirectory()) {
                addDir(files[i], out);
                continue;
            }
            FileInputStream in = new FileInputStream(files[i].getAbsolutePath());
            Logger.info(" Adding: " + files[i].getAbsolutePath());
            out.putNextEntry(new ZipEntry(files[i].getAbsolutePath()));
            int len;
            while ((len = in.read(tmpBuf)) &gt; 0) {
                out.write(tmpBuf, 0, len);
            }
            out.closeEntry();
            in.close();
        }
    }
  }
  </code></pre>
  
  <p>When reviewing the logging information, the files within the directories are being found and processed, but the created zip file contains no data.</p>
  
  <p>Any help with this issues will be greatly appreciated.</p>
  
  <p>Thanks</p>