You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2007/02/11 06:47:42 UTC
svn commit: r505846 -
/incubator/uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/examples/cpe/FileSystemCollectionReader.java
Author: schor
Date: Sat Feb 10 21:47:42 2007
New Revision: 505846
URL: http://svn.apache.org/viewvc?view=rev&rev=505846
Log:
UIMA-210 fixed by removing code that read a file -> string,
replaced with call to FileUtils.file2string. One issue:
this method is in ...uima.internal.util package.
Modified:
incubator/uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/examples/cpe/FileSystemCollectionReader.java
Modified: incubator/uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/examples/cpe/FileSystemCollectionReader.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/examples/cpe/FileSystemCollectionReader.java?view=diff&rev=505846&r1=505845&r2=505846
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/examples/cpe/FileSystemCollectionReader.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-examples/src/main/java/org/apache/uima/examples/cpe/FileSystemCollectionReader.java Sat Feb 10 21:47:42 2007
@@ -30,6 +30,7 @@
import org.apache.uima.collection.CollectionException;
import org.apache.uima.collection.CollectionReader_ImplBase;
import org.apache.uima.examples.SourceDocumentInformation;
+import org.apache.uima.internal.util.FileUtils;
import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.tcas.DocumentAnnotation;
import org.apache.uima.resource.ResourceConfigurationException;
@@ -120,22 +121,9 @@
// open input stream to file
File file = (File) mFiles.get(mCurrentIndex++);
- BufferedInputStream fis = new BufferedInputStream(new FileInputStream(file));
- try {
- byte[] contents = new byte[(int) file.length()];
- fis.read(contents);
- String text;
- if (mEncoding != null) {
- text = new String(contents, mEncoding);
- } else {
- text = new String(contents);
- }
+ String text = FileUtils.file2String(file, mEncoding);
// put document in CAS
- jcas.setDocumentText(text);
- } finally {
- if (fis != null)
- fis.close();
- }
+ jcas.setDocumentText(text);
// set language if it was explicitly specified as a configuration parameter
if (mLanguage != null) {