Hi, I have a problem that has to do more with java than with lucene. I have a folder that has about 524 text files (.txt) that I want to index. I have made a program that works very well. It does indexing searching etc... ... IndexWriter writer; GreekAnalyzer anal = new GreekAnalyzer(); try { writer = new IndexWriter(indexPath,anal, true); for (int i = 1; i <=524; i++) {
File indexFile = new File("/database/" +i+ ".txt"); InputStream fis = new FileInputStream(indexFile); /* * We use a Document with four fields: the file path, the last modified date * the length of the file and one the file's contents. */ Document doc = new Document(); doc.add(Field.UnIndexed("path", indexFile.getPath())); doc.add(Field.UnIndexed("length",Long.toString( indexFile.length()))); doc.add(Field.UnIndexed("modified",new Date( indexFile.lastModified()).toString())); doc.add(Field.Text("text", (Reader) new InputStreamReader(fis))); writer.addDocument(doc); fis.close(); } .... My problem is that I want to delete the for loop and write the program in a way to read all the files I want to index and there are in a folder. I have other folders as well that have txt files as well but they are not 524 so I can not use the for loop. I hope that you understand what I mean because I don't use the English language very well. Thank you very much Kostas