From be689f7135b4b860e8ee56eef16a5871a4a16b15 Mon Sep 17 00:00:00 2001 From: samskivert Date: Sun, 12 Jul 2009 21:24:48 +0000 Subject: [PATCH] Another convenience. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2590 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 1912b22b..2ee5c7ea 100644 --- a/src/java/com/samskivert/io/StreamUtil.java +++ b/src/java/com/samskivert/io/StreamUtil.java @@ -105,6 +105,15 @@ public class StreamUtil return out; } + /** + * Reads the contents of the supplied stream into a byte array. + */ + public static byte[] toByteArray (InputStream stream) + throws IOException + { + return copy(stream, new ByteArrayOutputStream()).toByteArray(); + } + /** * Reads the contents of the supplied stream into a string using the supplied {@link Charset}. */