[logback-dev] svn commit: r1229 - logback/trunk/logback-access/src/main/java/ch/qos/logback/access/spi

noreply.ceki at qos.ch noreply.ceki at qos.ch
Tue Jan 16 16:02:15 CET 2007


Author: ceki
Date: Tue Jan 16 16:02:14 2007
New Revision: 1229

Modified:
   logback/trunk/logback-access/src/main/java/ch/qos/logback/access/spi/Util.java

Log:
probably a more robust implementation

Modified: logback/trunk/logback-access/src/main/java/ch/qos/logback/access/spi/Util.java
==============================================================================
--- logback/trunk/logback-access/src/main/java/ch/qos/logback/access/spi/Util.java	(original)
+++ logback/trunk/logback-access/src/main/java/ch/qos/logback/access/spi/Util.java	Tue Jan 16 16:02:14 2007
@@ -1,20 +1,20 @@
 package ch.qos.logback.access.spi;
 
-import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 
 public class Util {
-
+  static final int BUF_SIZE= 128;
+  
   public static String readToString(InputStream in) throws IOException {
-    StringBuffer sb = new StringBuffer();
-    BufferedReader inbr = new BufferedReader(new InputStreamReader(in));
-    String line;
-    while ((line = inbr.readLine()) != null) {
-      sb.append(line);
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    byte[] buf = new byte[BUF_SIZE];
+    int n = 0;
+    while( (n = in.read(buf, 0, BUF_SIZE)) != -1) {
+      baos.write(buf, 0, n);
     }
-
-    return sb.toString();
+    
+    return baos.toString();
   }
 }



More information about the logback-dev mailing list