I have a file open and write situation that crashes with EOFException once in about 20-30 times, because the file is unavailable because some other process is writing to it.
Can I catch this exception, then somehow wait for the file write operation synchronously to end, so I can recurse the method?
File productJSON = getFileStreamPath("product" + "_" + getId() + ".json");
if (!productJSON.exists()) {
productJSON = getFileStreamPath("product" + ".json");
}
InputStream jsonStringsFileInputStream;
try {
jsonStringsFileInputStream = new FileInputStream(productJSON);
HashMap<String, Map> that = new JSONToProductParser().convertThisToThat(jsonStringsFileInputStream);
} catch (FileNotFoundException e) {
e.printStackTrace();
}