title: Using Java nio to create a subdirectory and file
body: <p>I'm creating a simple program that will try to read in "conf/conf.xml" from disk, but if this file or dir doesn't exist will instead create them.</p>
  
  <p>I can do this using the following code:</p>
  
  <pre><code>    // create subdirectory path
      Path confDir = Paths.get("./conf"); 
  
      // create file-in-subdirectory path
      Path confFile = Paths.get("./conf/conf.xml"); 
  
      // if the sub-directory doesn't exist then create it
      if (Files.notExists(confDir)) { 
          try { Files.createDirectory(confDir); }
          catch (Exception e ) { e.printStackTrace(); }
      }
  
      // if the file doesn't exist then create it
      if (Files.notExists(confFile)) {
          try { Files.createFile(confFile); }
          catch (Exception e ) { e.printStackTrace(); }
      }
  </code></pre>
  
  <p>My questions is if this really the most elegant way to do this? It seems superflous to need to create two Paths simple to create a new file in a new subdirectory.</p>