package meetlucene;

import java.io.File;
import java.io.IOException;

import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.Version;

/**
 * chapter 1.4
 * @author Zhang Gang
 * @date 2014年10月23日
 */
public class Indexer {

	public static void main(String[] args) throws Exception{
		if (args.length != 2){
			throw new IllegalArgumentException("Usage: java "
					+ Indexer.class.getName() + " <index dir> <data dir>");
		}
		String indexDir = args[0];
		String dataDir = args[1];
		long start = System.currentTimeMillis();
		Indexer indexer = new Indexer(indexDir);
		
	}
	
	private IndexWriter writer;
	
	public Indexer(String indexDir) throws IOException{
		Directory dir = FSDirectory.open(new File(indexDir));
		writer = new IndexWriter(dir, new StandardAnalyzer(Version.LUCENE_30), true, IndexWriter.MaxFieldLength.UNLIMITED);
		
	}

}

@@ -524,14 +524,9 @@
 va %22
-%0A%09%09%09%09%09
+ 
 + In
@@ -547,16 +547,22 @@
 tName() 
+%0A%09%09%09%09%09
 + %22 %3Cind
@@ -730,19 +730,16 @@
 exDir);%0A
-%09%09%0A
 %09%7D%0A%09%0A%09pr
@@ -954,16 +954,21 @@
 , true, 
+%0A%09%09%09%09
 IndexWri
@@ -999,16 +999,77 @@
 ITED);%0A%09
-%09
+%7D%0A%09%0A%09public void close() throws IOException%7B%0A%09%09writer.close();
 %0A%09%7D%0A%0A%7D%0A

修改Indexer.java