1 package ch.qos.logback.access.spi; 2 3 import java.io.ByteArrayOutputStream; 4 import java.io.IOException; 5 import java.io.InputStream; 6 7 public class Util { 8 static final int BUF_SIZE= 128; 9 10 public static String readToString(InputStream in) throws IOException { 11 if(in == null) { 12 return null; 13 } 14 ByteArrayOutputStream baos = new ByteArrayOutputStream(); 15 byte[] buf = new byte[BUF_SIZE]; 16 int n = 0; 17 while( (n = in.read(buf, 0, BUF_SIZE)) != -1) { 18 baos.write(buf, 0, n); 19 } 20 return baos.toString(); 21 } 22 }