exists()
tests if a file exists, and is thus, logically, part of the class java.io.File, and not of the class String. So the code should be
File file = new File("MyStore.obj");
if (!file.exists()) {
throw new FileNotFoundException("file doesn't exist");
}
Doing this check after opening a FileInputStream to the same file doesn't make much sense though, since the FileInputStream would already have thrown a FileNotFoundException if the file doesn't exist, as its javadoc indicates.