title: Create a directory if it does not exist and then create the files in that directory as well
body: <p>The condition is if the directory exists it has to create files in that specific directory without creating a new directory.</p>
  <p>The below code only creates a file with the new directory but not for the existing directory . For example the directory name would be like &quot;GETDIRECTION&quot;:</p>
  <pre class="lang-java prettyprint-override"><code>String PATH = &quot;/remote/dir/server/&quot;;
      
  String fileName = PATH.append(id).concat(getTimeStamp()).append(&quot;.txt&quot;);  
               
  String directoryName = PATH.append(this.getClassName());   
                
  File file  = new File(String.valueOf(fileName));
  
  File directory = new File(String.valueOf(directoryName));
  
  if (!directory.exists()) {
          directory.mkdir();
          if (!file.exists() &amp;&amp; !checkEnoughDiskSpace()) {
              file.getParentFile().mkdir();
              file.createNewFile();
          }
  }
  FileWriter fw = new FileWriter(file.getAbsoluteFile());
  BufferedWriter bw = new BufferedWriter(fw);
  bw.write(value);
  bw.close();
  
  </code></pre>