dnaber      2004/09/02 14:33:57

  Modified:    src/demo/org/apache/lucene/demo FileDocument.java
  Log:
  use a FileReader and delete the comment that asks why it doesn't work - because it 
does now. also mention which encoding is expected.
  
  Revision  Changes    Path
  1.6       +4 -8      jakarta-lucene/src/demo/org/apache/lucene/demo/FileDocument.java
  
  Index: FileDocument.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-lucene/src/demo/org/apache/lucene/demo/FileDocument.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FileDocument.java 2 Sep 2004 21:23:14 -0000       1.5
  +++ FileDocument.java 2 Sep 2004 21:33:57 -0000       1.6
  @@ -17,10 +17,7 @@
    */
   
   import java.io.File;
  -import java.io.Reader;
  -import java.io.FileInputStream;
  -import java.io.BufferedReader;
  -import java.io.InputStreamReader;
  +import java.io.FileReader;
   
   import org.apache.lucene.document.Document;
   import org.apache.lucene.document.Field;
  @@ -59,10 +56,9 @@
   
       // Add the contents of the file to a field named "contents".  Specify a Reader,
       // so that the text of the file is tokenized and indexed, but not stored.
  -    // ?? why doesn't FileReader work here ??
  -    FileInputStream is = new FileInputStream(f);
  -    Reader reader = new BufferedReader(new InputStreamReader(is));
  -    doc.add(new Field("contents", reader));
  +    // Note that FileReader expects the file to be in the system's default encoding.
  +    // If that's not the case searching for special characters will fail.
  +    doc.add(new Field("contents", new FileReader(f)));
   
       // return the document
       return doc;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to