try {
nlFile = URLFactory.createURL(naturalLanguageDir, fileName);
} catch (final MalformedURLException e) {
/* This probably means that the hyphenation URL is not valid.
* Rethrow the exception to alert the user. */
throw new HyphenationException(e);
}
InputStream inputStream = null;
try {
inputStream = nlFile.openStream();
} catch (final IOException e) {
/* This just means that the input doesn't exist. Ignore the
* exception as the null value in "inputStream" will control the
* downstream logic. */
}
if (inputStream != null) {
ObjectInputStream ois = null;
try {
ois = new ObjectInputStream(inputStream);
nl = (NaturalLanguage) ois.readObject();
return nl;
} catch (final IOException e) {
throw new HyphenationException(e);
} catch (final ClassNotFoundException e) {
throw new HyphenationException(e);
} finally {
if (ois != null) {
try {
ois.close();
} catch (final IOException e) {
this.logger.error(
"Exception closing ObjectInputStream "
+ "for " + nlFile.toString(), e);
}
}
}
}
/* Look for the raw XML file. */
fileName = filePrefix + ".xml";
try {
nlFile = URLFactory.createURL(naturalLanguageDir, fileName);
} catch (final MalformedURLException e) {
/* This probably means that the hyphenation URL is not valid.
* Rethrow the exception to alert the user. */
throw new HyphenationException(e);
}
/* Does the XML file exist? */
try {
inputStream = nlFile.openStream();