2012-10-01 40 views
1

我在使用lucene進行索引和在客戶端搜索後搜索關鍵字我想在那裏顯示html文件。那麼是否有任何方法來存儲和訪問HTML文件。實際上html文件存儲圖像和鏈接,它們應該作爲普通的html文件在java api中打開。 我使用的Lucene索引下面的代碼爲客戶端加密的html文件

try 
    { 

     IndexWriter indexWriter = new IndexWriter(

     FSDirectory.open(indexDir), 

     new SimpleAnalyzer(), 

     true, 
     IndexWriter.MaxFieldLength.LIMITED); 
     indexWriter.setUseCompoundFile(false); 
     indexDirectory(indexWriter, dataDir, suffix); 

     Document doc = new Document(); 

     doc.add(new Field("contents", new FileReader(f))); 

     doc.add(new Field("filename",f.getCanonicalPath(), 

     Field.Store.YES,Field.Index.ANALYZED)); 
     indexWriter.addDocument(doc); 

     numIndexed = indexWriter.maxDoc(); 

     indexWriter.optimize(); 

     indexWriter.close(); 

     } 

     catch(Exception ex) 
     { 
     } 

我應該如何顯示HTML文件匹配客戶端上的搜索條件

+0

正如所寫(甚至編輯後),你的問題是無法解讀的。什麼HTML文件?這些文件是如何被添加到Lucene的,它們存儲在哪裏?你在談論桌面(Swing)客戶端還是Web客戶端?客戶是否可以訪問原始文件? – parsifal

+1

我的建議是,您退一步,繪製應用程序的框圖,然後再提出您的問題。除非這個代碼在某種程度上與你的問題有關(它看起來像將一個文檔添加到Lucene索引的通用代碼),只需將其刪除即可。 – parsifal

回答

3

你可能會尋找browse(),其中「啓動默認瀏覽器來顯示一個URI「。或者,可以使用editor pane,但支持是limited

+0

對'browse()':)的+1創意思考 –

+1

@David:我很難在(垃圾箱)之外思考。 :-) – trashgod