cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1393139 - /cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
Date Tue, 02 Oct 2012 19:44:58 GMT
Author: dkulp
Date: Tue Oct  2 19:44:58 2012
New Revision: 1393139

URL: http://svn.apache.org/viewvc?rev=1393139&view=rev
Log:
Merged revisions 1393109 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes

........
  r1393109 | dkulp | 2012-10-02 15:09:33 -0400 (Tue, 02 Oct 2012) | 10 lines

  Merged revisions 1393095 via  git cherry-pick from
  https://svn.apache.org/repos/asf/cxf/trunk

  ........
    r1393095 | dkulp | 2012-10-02 14:50:19 -0400 (Tue, 02 Oct 2012) | 2 lines

    [CXF-4533] Use a Reader to read from the input stream as chars instead of trying to handle
it ourselves.

  ........

........

Modified:
    cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java

Modified: cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java?rev=1393139&r1=1393138&r2=1393139&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java (original)
+++ cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java Tue
Oct  2 19:44:58 2012
@@ -28,9 +28,11 @@ import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.PipedInputStream;
 import java.io.PipedOutputStream;
+import java.io.Reader;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -307,21 +309,23 @@ public class CachedOutputStream extends 
         } else {
             // read the file
             FileInputStream fin = new FileInputStream(tempFile);
-            byte bytes[] = new byte[1024];
-            long x = fin.read(bytes);
+            Reader reader = new InputStreamReader(fin, charsetName);
+            char bytes[] = new char[1024];
+            long x = reader.read(bytes);
             while (x != -1) {
                 if ((count + x) > limit) {
                     x = limit - count;
                 }
-                out.append(IOUtils.newStringFromBytes(bytes, charsetName, 0, (int)x));
+                out.append(bytes, 0, (int)x);
                 count += x;
 
                 if (count >= limit) {
                     x = -1;
                 } else {
-                    x = fin.read(bytes);
+                    x = reader.read(bytes);
                 }
             }
+            reader.close();
             fin.close();
         }
     }
@@ -342,12 +346,14 @@ public class CachedOutputStream extends 
         } else {
             // read the file
             FileInputStream fin = new FileInputStream(tempFile);
-            byte bytes[] = new byte[1024];
-            int x = fin.read(bytes);
+            Reader reader = new InputStreamReader(fin, charsetName);
+            char bytes[] = new char[1024];
+            int x = reader.read(bytes);
             while (x != -1) {
-                out.append(IOUtils.newStringFromBytes(bytes, charsetName, 0, x));
-                x = fin.read(bytes);
+                out.append(bytes, 0, x);
+                x = reader.read(bytes);
             }
+            reader.close();
             fin.close();
         }
     }



Mime
View raw message