I am happy to receive all recommendations for improvement. But below I am mostly interested in a review of my handling of the exception thrown by the close()
method of RandomAccessFile
.
The FileNotFoundException
thrown by the opening of a file (in the constructor of RandomAccessFile
) is declared as thrown by my method, because the caller can act on it.
But the exception thrown by the close() method on that file cannot be handled the caller, so I repackage it in a RuntimeException
.
private boolean includeArticle(File articleFile, Map<String, String> conditionMap)
throws FileNotFoundException
{
if (doesFileQualifyAsArticle(articleFile)) {
/* This can throw a FileNotFoundException, which the caller should know about. */
RandomAccessFile raFile = new RandomAccessFile(articleFile, "r");
if (this.isToInclude(raFile, conditionMap)) {
return true;
}
try {
raFile.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return false;
}