title: How to create a file in java (not a folder) ?
body: <p>Perhaps somewhat embarassing, but after some hours I still cannot create a file in Java...</p>
  
  <pre><code>File file = new File(dirName + "/" + fileName);
  try
  {
      // --&gt; ** this statement gives an exception 'the system cannot find the path'
      file.createNewFile();
      // --&gt; ** this creates a folder also named a directory with the name fileName
      file.mkdirs();
      System.out.println("file != null");
      return file;
  }
  catch (Exception e)
  {
      System.out.println(e.getMessage());
      return null;
  }
  </code></pre>
  
  <p>What am I missing here?</p>