title: Java Files.write NoSuchFileException
body: <p>I'm trying to write some text to a file using <code>Files.write()</code> method.  </p>
  
  <pre><code>byte[] contents = project.getCode().getBytes(StandardCharsets.UTF_8);
  
  try {
      Files.write(project.getFilePath(), contents, StandardOpenOption.CREATE);
  } catch (IOException ex) {
      ex.printStackTrace();
      return;
  }
  </code></pre>
  
  <p>According to the API, if the file doesn't exist, it will be created and then written to.  </p>
  
  <p>However, I get this:  </p>
  
  <pre><code>java.nio.file.NoSuchFileException: C:\Users\Administrator\Desktop\work\Default.txt
      at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
      at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
      at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
      at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(Unknown Source)
      at java.nio.file.spi.FileSystemProvider.newOutputStream(Unknown Source)
      at java.nio.file.Files.newOutputStream(Unknown Source)
      at java.nio.file.Files.write(Unknown Source)
  </code></pre>
  
  <p>Am I missing something?</p>