How can I check whether a file exists, before openinging it for reading in Java? (equivalent of Perl's -e $filename
).
The only similar question on SO dealt with writing the file and was thus answered using FileWriter which is obviously not applicable here.
If possible I'd prefer a real API 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 text", but I can live with the latter.