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/01/20 01:53:10 UTC

svn commit: r498023 - /incubator/uima/uimaj/trunk/uimaj-jet-expander/src/org/apache/uima/util/jet/JetExpander.java

Author: schor
Date: Fri Jan 19 16:53:10 2007
New Revision: 498023

URL: http://svn.apache.org/viewvc?view=rev&rev=498023
Log:
UIMA-210  Changed xxx.read(buffer) in many places to insure
all bytes/chars are read.  Sometimes the read was wrapped in
a while loop.  Othertimes, I substituted BufferedXXX for the
non buffered readers/input-streams.  The .read(buf) for the
buffered versions has the "while loop" built in, according to
the javadocs.  For BufferedReader, I used the form
.read(buf, 0, length) as that was the only form that the 
javadoc said it did this for.

Modified:
    incubator/uima/uimaj/trunk/uimaj-jet-expander/src/org/apache/uima/util/jet/JetExpander.java

Modified: incubator/uima/uimaj/trunk/uimaj-jet-expander/src/org/apache/uima/util/jet/JetExpander.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-jet-expander/src/org/apache/uima/util/jet/JetExpander.java?view=diff&rev=498023&r1=498022&r2=498023
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-jet-expander/src/org/apache/uima/util/jet/JetExpander.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-jet-expander/src/org/apache/uima/util/jet/JetExpander.java Fri Jan 19 16:53:10 2007
@@ -18,6 +18,7 @@
  */
 package org.apache.uima.util.jet;
 
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
@@ -98,19 +99,17 @@
 	}
 	
 	String readFile(String fileName) {
-		
+ 		
     char [] buffer;
     
     try {
 			File file = new File((new File(fileName)).getCanonicalPath());
    	
-			FileReader fileReader = new FileReader(file.getCanonicalPath());
+			BufferedReader fileReader = new BufferedReader(new FileReader(file.getCanonicalPath()));
 			int fileLength = (int)file.length();
 			buffer = new char [fileLength];
-			int charsRead = fileReader.read(buffer);
-			if (charsRead != fileLength)
-			  throw new ErrorExit("Read different length than whats in the file.");
-			
+      // this form with 3 args is the only one the Javadoc says will read all of the file
+			fileReader.read(buffer, 0, fileLength);			
 			return new String(buffer).replaceAll("\\r","");  // for linux/unix
 //			return new String(buffer);  
 		} catch (FileNotFoundException e) {