From bb8468bec634cfecce0f7cb7b4ac0df6a847d89b Mon Sep 17 00:00:00 2001 From: Daniel Naber Date: Thu, 2 Sep 2004 21:33:57 +0000 Subject: [PATCH] use a FileReader and delete the comment that asks why it doesn't work - because it does now. also mention which encoding is expected. git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150479 13f79535-47bb-0310-9956-ffa450edef68 --- src/demo/org/apache/lucene/demo/FileDocument.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/demo/org/apache/lucene/demo/FileDocument.java b/src/demo/org/apache/lucene/demo/FileDocument.java index 862d0bcfc2a..2d68e3ef114 100644 --- a/src/demo/org/apache/lucene/demo/FileDocument.java +++ b/src/demo/org/apache/lucene/demo/FileDocument.java @@ -17,10 +17,7 @@ package org.apache.lucene.demo; */ 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 @@ public class FileDocument { // 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;