title: Java Servlet check if a file exists or create it
body: <p>With the folloing check I get an error... because I try to load a file that not exists... how can I do this check safely?</p>
  
  <pre><code>File file = new File(getClass().getResource("/file.xml").getFile());
  
  if(file.exists()==false){
  
      //CREATE THE FILE
  
  
      }
  
      else{
  
      //UPDATE THE FILE
      }
  </code></pre>