title: How to create a new directory using java?
body: <p>I am using the following code to create folder but it does not create it (output is failed) and does not throw any exception.</p>
  
  <p>Folder java is already created, I need to pass the folder name and create it in the java folder.</p>
  
  <pre><code>private String CreateFolder(String myfolder) {
          try {
              String dir = "../Java/" + myfolder;
              boolean result = false;
              File directory = new File(dir);
  
              if (!directory.exists()) {
                  result = directory.mkdir();
  
                  if (result) {
                      System.out.println("Folder is created");
                      return dir;
                  } else {
                      return "failed";
                  }
              }
          }catch(Exception e) {
              e.printStackTrace();
          }
          return "";
      }
  </code></pre>