title: Is it possible to create a NEW zip file using the java FileSystem?
body: <p>I've successfully modified the contents of a (existing) zip file using the <code>FileSystem</code> provided by java 7, but when I tried to create a NEW zip file by this method it fails, with the error message that says: <code>"zip END header not found"</code>, it is logical because of the way I'm doing it, first I create the file (<code>Files.createFile</code>) which is a completely empty file, and then I try to access to its file system , and since the file is empty its impossible to find any header inside the zip, <strong>my question is</strong> is there any way to create a new zip file completely empty using this method?; the hack that I've considered is adding an empty new <code>ZipEntry</code> to a the zip file and then using that new empty file to crate the file system based on it, but i really want to think that the guys of oracle implemented a better (easier) way to do this with nio and the filesystems...</p>
  
  <p>this is my code (the error appears when creating the file system):</p>
  
  <pre><code>if (!zipLocation.toFile().exists()) {
          if (creatingFile) {
              Files.createFile(zipLocation);
          }else {
              return false;
          }
      } else if (zipLocation.toFile().exists() &amp;&amp; !replacing) {
          return false;
      } 
      final FileSystem fs = FileSystems.newFileSystem(zipLocation, null);
  .
  .
  .
  </code></pre>
  
  <p><code>zipLocation</code> is a Path
  <code>creatingFile</code> is a boolean</p>
  
  <p><strong>ANSWER:</strong>
  in my particular case the answer given didn't work appropriately because of the spaces in the path, therefore i have to do it the way i didn't want to: </p>
  
  <pre><code>Files.createFile(zipLocation);
  ZipOutputStream out = new ZipOutputStream(
      new FileOutputStream(zipLocation.toFile()));
  out.putNextEntry(new ZipEntry(""));
  out.closeEntry();
  out.close();
  </code></pre>
  
  <p><strong>it does not mean that the given answer is wrong, it just didn't work for my particular case</strong></p>