title: Cannot make file java.io.IOException: No such file or directory
body: <p>I am trying to create a file on the filesystem, but I keep getting this exception:</p>
  
  <pre><code>java.io.IOException: No such file or directory
  </code></pre>
  
  <p>I have an existing directory, and I am trying to write a file to that directory.</p>
  
  <pre><code>// I have also tried this below, but get same error
  // new File(System.getProperty("user.home") + "/.foo/bar/" + fileName);
  
  File f = new File(System.getProperty("user.home") + "/.foo/bar/", fileName);
  
  if (f.exists() &amp;&amp; !f.canWrite())
          throw new IOException("Kan ikke skrive til filsystemet " + f.getAbsolutePath());
  
  if (!f.isFile()) {
      f.createNewFile(); // Exception here
  } else {
      f.setLastModified(System.currentTimeMillis());
  }
  </code></pre>
  
  <p>Getting exception:</p>
  
  <pre><code>java.io.IOException: No such file or directory
    at java.io.UnixFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(File.java:883)`
  </code></pre>
  
  <p>I have write permission to the path, however the file isn't created.</p>