title: Creating File & Directories not working properly
body: <p>I am currently working on a method that will create files and directories. Bellow is the use case &amp; problem explained.</p>
  
  <p>1) When a user specifies a path e.g "/parent/sub folder/file.txt", the system should be able to create the directory along with the file.txt. (This one works)</p>
  
  <p>2) When a user specifies a path e.g "/parent/sub-folder/" or "/parent/sub-folder", the system should be able to create all directories. (Does not work), Instead of it creating the "/sub-folder/" or /sub-folder" as a folder, it will create a file named "sub-folder".</p>
  
  <p>Here is the code I have</p>
  
  <pre><code>Path path = Paths.get(rootDir+"test/hello/");
      try {
          Files.createDirectories(path.getParent());
          if (!Files.isDirectory(path)) {
              Files.createFile(path);
          } else {
              Files.createDirectory(path);
          }
      } catch (IOException e) {
          System.out.println(e.getMessage());
      }
  </code></pre>