Community
Participate
Working Groups
Version: 3.0.0 Build id: 200406251208 The following source isn't formatted when I select Source|Format. When the 'Index.class' expressions in printUsage are removed (or converted to Strings by introducing '"') the format works. I hope you are able to find it. -------- begin source ------- package tms.intranet.search; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Date; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.demo.HTMLDocument; import org.apache.lucene.document.Document; import org.apache.lucene.index.IndexWriter; /** * Creates index for static directory tree. * * @author h.koch */ public class Index { public static void indexDocs(IndexWriter writer, File file) throws IOException, InterruptedException { // do not try to index files that cannot be read if (file.canRead()) { if (file.isDirectory()) { String[] files = file.list(); // an IO error could occur if (files != null) { for (int i = 0; i < files.length; i++) { indexDocs(writer, new File(file, files[i])); } } } else if(filter.accept(file)) { System.out.println("adding " + file); Document doc = null; try { if(htmlFilter.accept(file)) { doc = HTMLDocument.Document(file); } else { doc = MiscFileDocument.Document(file); } writer.addDocument(doc); } catch (FileNotFoundException fnfe) { // at least on windows, some temporary files raise this exception // with an "access denied" message // checking if the file can be read doesn't help ; } } } } private static void printUsage() { System.out.println("Usage: " + Index.class + " <relative path to root dir> <path to index dir>"); System.out.println("Example:"); System.out.println("From a subdirectory of your htdocs dir call"); System.out.println("java " + Index.class + " .. /usr/local/share/search/index"); System.out.println("to place an index in /usr/local/share/search/index (must exist)"); } private static final IndexFileFilter filter = new IndexFileFilter(); private static final HTMLFileFilter htmlFilter = new HTMLFileFilter(); } ----- end source ------------
*** This bug has been marked as a duplicate of 66452 ***