You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by bd...@apache.org on 2007/03/21 10:29:22 UTC
svn commit: r520817 -
/lucene/solr/trunk/src/java/org/apache/solr/util/SimplePostTool.java
Author: bdelacretaz
Date: Wed Mar 21 02:29:22 2007
New Revision: 520817
URL: http://svn.apache.org/viewvc?view=rev&rev=520817
Log:
SOLR-194: use fixed UTF-8 encoding to read the files to POST
Modified:
lucene/solr/trunk/src/java/org/apache/solr/util/SimplePostTool.java
Modified: lucene/solr/trunk/src/java/org/apache/solr/util/SimplePostTool.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/util/SimplePostTool.java?view=diff&rev=520817&r1=520816&r2=520817
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/util/SimplePostTool.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/util/SimplePostTool.java Wed Mar 21 02:29:22 2007
@@ -17,22 +17,23 @@
* limitations under the License.
*/
-import java.io.IOException;
-import java.io.FileNotFoundException;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
import java.io.Reader;
-import java.io.FileReader;
import java.io.StringReader;
-import java.io.InputStreamReader;
-import java.io.InputStream;
import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
import java.io.Writer;
-import java.io.OutputStreamWriter;
-import java.io.OutputStream;
-import java.net.URL;
-import java.net.ProtocolException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
+import java.net.ProtocolException;
+import java.net.URL;
/**
* A simple utility class for posting raw updates to a Solr server,
@@ -147,11 +148,14 @@
/**
* Opens the file and posts it's contents to the solrUrl,
* writes to response to output.
+ * @throws UnsupportedEncodingException
*/
public void postFile(File file, Writer output)
- throws FileNotFoundException {
+ throws FileNotFoundException, UnsupportedEncodingException {
- FileReader reader = new FileReader(file);
+ // FIXME; use a real XML parser to read files, so as to support various encodings
+ // (and we can only post well-formed XML anyway)
+ Reader reader = new InputStreamReader(new FileInputStream(file),POST_ENCODING);
try {
postData(reader, output);
} finally {