show a useful error message if the directory to index doesn't exist or isn't readable.

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150647 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bernhard Messer 2004-11-18 18:54:13 +00:00
parent 34c106218e
commit d9f00f1d09

View File

@ -40,11 +40,17 @@ class IndexFiles {
System.exit(1);
}
final File docDir = new File(args[0]);
if (!docDir.exists() || !docDir.canRead()) {
System.out.println("Document directory '" +docDir.getAbsolutePath()+ "' does not exist or is not readable, please check the path");
System.exit(1);
}
Date start = new Date();
try {
IndexWriter writer = new IndexWriter(INDEX_DIR, new StandardAnalyzer(), true);
System.out.println("Indexing to directory '" +INDEX_DIR+ "'...");
indexDocs(writer, new File(args[0]));
indexDocs(writer, docDir);
System.out.println("Optimizing...");
writer.optimize();
writer.close();