From b5af1884b34baa8f3ca11230050ea1b2882e4b29 Mon Sep 17 00:00:00 2001 From: samskivert Date: Mon, 13 Jul 2009 02:21:06 +0000 Subject: [PATCH] Sometimes the platform default charset is appropriate. Like when you're turning the results of Process.getOutputStream() into a string. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2592 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- src/java/com/samskivert/io/StreamUtil.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/java/com/samskivert/io/StreamUtil.java b/src/java/com/samskivert/io/StreamUtil.java index 2ee5c7ea..8315ff97 100644 --- a/src/java/com/samskivert/io/StreamUtil.java +++ b/src/java/com/samskivert/io/StreamUtil.java @@ -114,6 +114,15 @@ public class StreamUtil return copy(stream, new ByteArrayOutputStream()).toByteArray(); } + /** + * Reads the contents of the supplied stream into a string using the platform default charset. + */ + public static String toString (InputStream stream) + throws IOException + { + return copy(stream, new ByteArrayOutputStream()).toString(); + } + /** * Reads the contents of the supplied stream into a string using the supplied {@link Charset}. */