How can I check whether a file exists, before opening it for reading in Java (the equivalent of Perl\'s -e $filename>
-e $filename>
first hit for "java file exists" on google:
import java.io.*; public class FileTest { public static void main(String args[]) { File f = new File(args[0]); System.out.println(f + (f.exists()? " is found " : " is missing ")); } }