2828import java .io .OutputStreamWriter ;
2929import java .io .PrintWriter ;
3030import java .io .Reader ;
31- import java .io .StringWriter ;
3231import java .io .Writer ;
3332import java .nio .channels .Channel ;
3433import java .util .ArrayList ;
3736import java .util .List ;
3837
3938import org .apache .commons .io .output .ByteArrayOutputStream ;
39+ import org .apache .commons .io .output .StringBuilderWriter ;;
4040
4141/**
4242 * General IO stream manipulation utilities.
@@ -110,7 +110,7 @@ public class IOUtils {
110110 public static final String LINE_SEPARATOR ;
111111 static {
112112 // avoid security issues
113- StringWriter buf = new StringWriter (4 );
113+ StringBuilderWriter buf = new StringBuilderWriter (4 );
114114 PrintWriter out = new PrintWriter (buf );
115115 out .println ();
116116 LINE_SEPARATOR = buf .toString ();
@@ -374,7 +374,7 @@ public static char[] toCharArray(Reader input) throws IOException {
374374 * @throws IOException if an I/O error occurs
375375 */
376376 public static String toString (InputStream input ) throws IOException {
377- StringWriter sw = new StringWriter ();
377+ StringBuilderWriter sw = new StringBuilderWriter ();
378378 copy (input , sw );
379379 return sw .toString ();
380380 }
@@ -397,7 +397,7 @@ public static String toString(InputStream input) throws IOException {
397397 */
398398 public static String toString (InputStream input , String encoding )
399399 throws IOException {
400- StringWriter sw = new StringWriter ();
400+ StringBuilderWriter sw = new StringBuilderWriter ();
401401 copy (input , sw , encoding );
402402 return sw .toString ();
403403 }
@@ -414,7 +414,7 @@ public static String toString(InputStream input, String encoding)
414414 * @throws IOException if an I/O error occurs
415415 */
416416 public static String toString (Reader input ) throws IOException {
417- StringWriter sw = new StringWriter ();
417+ StringBuilderWriter sw = new StringBuilderWriter ();
418418 copy (input , sw );
419419 return sw .toString ();
420420 }
0 commit comments