title: How do I check if a file exists in Java?
body: <blockquote>
    <p>How can I check whether a file exists, before opening it for reading in <strong>Java</strong> (the equivalent of <strong>Perl's</strong> <code>-e $filename</code>)?  </p>
  </blockquote>
  
  <p>The only <a href="https://stackoverflow.com/questions/1237235/check-file-exists-java">similar question on SO</a> deals with writing the file and was thus answered using <code>FileWriter</code> which is obviously not applicable here.</p>
  
  <p>If possible I'd prefer a real <em>API</em> call returning true/false as opposed to some "Call API to open a file and catch when it throws an exception which you check for 'no file' in the text", but I can live with the latter.</p>