How can I determine if a file I want to read from actually exists?
- by Imray
I'm learning Java, and I'm trying to write a program that can read from a .ser file, which I've already created with a writeTo method.
I want to know a given file exists in the system before I tell the program to read from it.
My code looks like this:
public boolean readFromSerializedFile(String fileName){
FileInputStream fileInStream = null;
ObjectInputStream objectInStream = null;
try{
fileInStream = new FileInputStream(fileName);
objectInStream = new ObjectInputStream(fileInStream);
Is there a simple way I can determine if the file with the name of the parameter exists in the root directory (or wherever else specified)?