private void initCustomDataIndex(String dataFile, Directory directory)
throws CorruptIndexException, LockObtainFailedException,
IOException {
BufferedReader dataReader = createDataBufferedReader(dataFile);
if (dataReader != null) {
IndexWriter indexWriter = new IndexWriter(directory,
new KeywordAnalyzer(), true);
try {
String aline = dataReader.readLine();
while (aline != null) {
StringTokenizer tokenizer = new StringTokenizer(aline,
"\n\r\f", false);
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken().trim();
if (token != null) {
Document doc = createDocument(token);
indexWriter.addDocument(doc);
}
}
aline = dataReader.readLine();
}
indexWriter.optimize();
} finally {
if (indexWriter != null) {
try {
indexWriter.close();
} catch (Exception e) {
logger.error(e);
}
}
if (dataReader != null) {