title: Is there a proper way to check for file/directory existence in Java?
body: <p><strong>Code:</strong> </p>
  
  <pre><code>String dir = //Path to the  directory
  File saveDir = new File(dir);
  //Here comes the existence check
  if(!saveDir.exists())
    saveDir.mkdirs();
  </code></pre>
  
  <p>This part of code is used to save files with a given directory path to file system. Before saving i want to check whether the given save directory exists. However the existence check do not seem to work in the way that i wanted. Without removing the if clause the desired directories are not created.I came across to this interesting stack question while searching for my problem. 
  <a href="https://stackoverflow.com/questions/3833127/alternative-to-file-exists-in-java">Alternative to File.exists() in Java</a>. As i understand java.io has this problem.  </p>
  
  <p>Is there a proper and safe way to check the existance of a directory or resource while doing file operations?</p>