hello,
I am try to make an index of 191 documents stored in 191 text files. I
developed a program, which works well with files containing single line,
but files with multiple lines posing a problem.So i added while loop to
completely extract data from each document. But it has some logical
error. Well the given code is an right approach to my problem? Kindly
give some guidelines.
StringBuffer sb = new StringBuffer();
Analyzer analyzer = new StandardAnalyzer();
boolean createFlag = true;
IndexWriter writer =
new IndexWriter(indexDir, analyzer, createFlag);
for (int i=1;i<=191;i++) {
Reader file = new InputStreamReader(new
FileInputStream("corpus\\doc" + i + ".txt"), "UTF-8");
BufferedReader buff = new BufferedReader(file);
while( (line = buff.readLine()) != null) {
sb.append(line);
}
Document document = new Document();
document.add(new Field("contents",sb.toString(),
Field.Store.NO, Field.Index.TOKENIZED));
writer.addDocument(document);
buff.close();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]