Code:
String dir = //Path to the directory
File saveDir = new File(dir);
//Here comes the existence check
if(!saveDir.exists())
saveDir.
Well, even if the check would be correct, you can never be sure that the directory still exists after the if
condition has been evaluated. Another process or user can just create/remove it. So you have to check if the operation fails (possibly catching the appropriate exception) anyway.
So you shouldn't rely on checks and expect the worst case always. (Well, the checks may be useful for preventing you from doing something unnecessary, or for asking user for confirmation etc. But they don't guarantee anything.)