I wonder if anyone knows why I may be getting a java.io.FileNotFoundException
when I'm trying to find a file that I know exists in the directory.
I think the following have something to do with it, please let me know if I'm correct or if there's something else:
- I downgraded my JVM from 1.7 to 1.6
- The file name contains two question marks, so the file is called
filename_?)?.data
While I was using JVM 1.7, the program was able to find the file and open it. However, after downgrading to 1.6, it looks like it can't find this particular file. So I'm thinking maybe JVM 1.6 can't read files w/ question marks in them.
Also, I double/triple checked and the file does exist in the directory my program is looking in (its able to find other files in there as well).
Here's my code below:
public Object readFromFile(String fileName) {
// Check for null
if (fileName == null || fileName.equals("")) return null;
Object obj = null;
ObjectInputStream input = null;
// Open file into (input)
try {
input = new ObjectInputStream(new FileInputStream(fileName + ".data"));
} catch (IOException e) {
e.printStackTrace();
}
// Read content of file into (obj)
try {
obj = input.readObject();
input.close();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return obj;
}