* @param termFile Der Ort, wo die Datei erstellt werden soll.
*
* @throws RegainException Wenn die Erstellung fehlgeschlagen ist.
*/
private void writeTermFile(File indexDir, File termFile) throws RegainException {
IndexReader reader = null;
FileOutputStream stream = null;
PrintWriter writer = null;
try {
reader = IndexReader.open(FSDirectory.open(indexDir), true);
stream = new FileOutputStream(termFile);
writer = new PrintWriter(stream);
writer.println("This file was generated by the crawler and contains all " + "terms in the index.");
writer.println("It's no error when endings like 'e', 'en', and so on " + "are missing.");
writer.println("They have been cuttet by the GermanAnalyzer and will be " + "cuttet from a search query too.");
writer.println();
// Write the terms
TermEnum termEnum = reader.terms();
int termCount;
if (WRITE_TERMS_SORTED) {
termCount = writeTermsSorted(termEnum, writer);
} else {
termCount = writeTermsSimply(termEnum, writer);
}
mLog.info("Wrote " + termCount + " terms into " + termFile.getAbsolutePath());
} catch (IOException exc) {
throw new RegainException("Writing term file failed", exc);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException exc) {
}
}
if (writer != null) {
writer.close();