You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2012/10/02 21:09:33 UTC
svn commit: r1393109 -
/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
Author: dkulp
Date: Tue Oct 2 19:09:33 2012
New Revision: 1393109
URL: http://svn.apache.org/viewvc?rev=1393109&view=rev
Log:
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.6.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java?rev=1393109&r1=1393108&r2=1393109&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java (original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java Tue Oct 2 19:09:33 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();
}
}