title: ZIP file created using Java showing empty when open with Windows Explorer
body: <p>The below code is used to zip normal text file. When I extract using WinRaR its showing the content properly, but when I open with Windows Explorer its empty, no file listed. I am using Windows 7 Enterprise (64 bit) operating system. Any idea why its not listing in Windows explorer? Thanks in advance.</p>
  
  <pre><code>File file = new File("F:\\sample.txt");
      byte[] buf = new byte[1024];
      String outFilename = "F:\\zipped_sample.zip";
      try {
        ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outFilename));
        FileInputStream in = new FileInputStream(file);
        out.putNextEntry(new ZipEntry(file.toString()));
        int len;
        while ((len = in.read(buf)) &gt; 0) {
          out.write(buf, 0, len);
          out.flush();
        }
        out.closeEntry();
        out.close();
        in.close();
      } catch (Exception e) {
        // log exception here
      }
  </code></pre>