1 package org.apache.lucene.demo; 2 3 18 19 import java.io.IOException ; 20 21 import org.apache.lucene.store.Directory; 22 import org.apache.lucene.store.FSDirectory; 23 import org.apache.lucene.index.IndexReader; 24 import org.apache.lucene.index.Term; 25 26 class DeleteFiles { 27 public static void main(String [] args) { 28 try { 29 Directory directory = FSDirectory.getDirectory("demo index", false); 30 IndexReader reader = IndexReader.open(directory); 31 32 35 38 for (int i = 0; i < reader.maxDoc(); i++) 39 reader.delete(i); 40 41 reader.close(); 42 directory.close(); 43 44 } catch (Exception e) { 45 System.out.println(" caught a " + e.getClass() + 46 "\n with message: " + e.getMessage()); 47 } 48 } 49 } 50 | Popular Tags |