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 07:02:59 UTC

svn commit: r505853 - /incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/components/FileSystemCollectionReader.java

Author: schor
Date: Sat Feb 10 22:02:58 2007
New Revision: 505853

URL: http://svn.apache.org/viewvc?view=rev&rev=505853
Log:
UIMA-210 fixed by removing code that read a file -> string,
replaced with call to FileUtils.file2string.  

Modified:
    incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/components/FileSystemCollectionReader.java

Modified: incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/components/FileSystemCollectionReader.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/components/FileSystemCollectionReader.java?view=diff&rev=505853&r1=505852&r2=505853
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/components/FileSystemCollectionReader.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/components/FileSystemCollectionReader.java Sat Feb 10 22:02:58 2007
@@ -19,7 +19,6 @@
 
 package org.apache.uima.tools.components;
 
-import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -35,6 +34,7 @@
 import org.apache.uima.collection.CollectionReaderDescription;
 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;
@@ -139,7 +139,7 @@
 
     // open input stream to file
     File file = (File) mFiles.get(mCurrentIndex++);
-    BufferedInputStream fis = new BufferedInputStream(new FileInputStream(file));
+    FileInputStream fis = new FileInputStream(file);
     if (!mXCAS) {
       try {
         // if there's a CAS Initializer, call it
@@ -147,14 +147,7 @@
           getCasInitializer().initializeCas(fis, aCAS);
         } else // No CAS Initiliazer, so read file and set document text ourselves
         {
-          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 text in JCas
           jcas.setDocumentText(text);
         }