lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dna...@apache.org
Subject cvs commit: jakarta-lucene/src/demo/org/apache/lucene/demo IndexFiles.java
Date Thu, 02 Sep 2004 21:45:23 GMT
dnaber      2004/09/02 14:45:23

  Modified:    src/demo/org/apache/lucene/demo IndexFiles.java
  Log:
  Don't just silently delete the "index" directory if it exists but throw an error. Be a bit
more verbose.
  
  Revision  Changes    Path
  1.5       +11 -3     jakarta-lucene/src/demo/org/apache/lucene/demo/IndexFiles.java
  
  Index: IndexFiles.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/demo/org/apache/lucene/demo/IndexFiles.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- IndexFiles.java	3 Aug 2004 21:47:11 -0000	1.4
  +++ IndexFiles.java	2 Sep 2004 21:45:23 -0000	1.5
  @@ -26,6 +26,8 @@
   
   class IndexFiles {
     
  +  static final File INDEX_DIR = new File("index");
  +  
     public static void main(String[] args) {
       String usage = "java org.apache.lucene.demo.IndexFiles <root_directory>";
       if (args.length == 0) {
  @@ -33,16 +35,22 @@
         System.exit(1);
       }
   
  +    if (INDEX_DIR.exists()) {
  +      System.out.println("Cannot save index to '" +INDEX_DIR+ "' directory, please delete
it first");
  +      System.exit(1);
  +    }
  +    
       Date start = new Date();
       try {
  -      IndexWriter writer = new IndexWriter("index", new StandardAnalyzer(), true);
  +      IndexWriter writer = new IndexWriter(INDEX_DIR, new StandardAnalyzer(), true);
  +      System.out.println("Indexing to directory '" +INDEX_DIR+ "'...");
         indexDocs(writer, new File(args[0]));
  +      System.out.println("Optimizing...");
         writer.optimize();
         writer.close();
   
         Date end = new Date();
  -      System.out.print(end.getTime() - start.getTime());
  -      System.out.println(" total milliseconds");
  +      System.out.println(end.getTime() - start.getTime() + " total milliseconds");
   
       } catch (IOException e) {
         System.out.println(" caught a " + e.getClass() +
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org


Mime
View raw message