I am writing a code that asks if a file path is null. If the path is null I need to return false. The problem that I am having is that the method is not returning false. I can't tell if the method is checking if the filePath
exists or not. Here is my code:
public boolean saveWordTable(List<Word> wordTable, String filePath) throws IOException {
FileOutputStream fos = new FileOutputStream(new File(filePath));
ObjectOutputStream oos = new ObjectOutputStream(fos);
if (wordTable == null) {
return false;
}
if (!(new File(filePath).exists())) {
return false;
}
try {
oos.writeObject(wordTable);
} catch (IOException e) {
//e.printStackTrace();
return false;
}
fos.close();
oos.close();
return true;
Any kind of help would be appreciated.