You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2013/04/20 20:06:24 UTC
svn commit: r1470213 -
/commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java
Author: sebb
Date: Sat Apr 20 18:06:24 2013
New Revision: 1470213
URL: http://svn.apache.org/r1470213
Log:
Add support for Charset encoding (already supports String)
Modified:
commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java?rev=1470213&r1=1470212&r2=1470213&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java Sat Apr 20 18:06:24 2013
@@ -375,4 +375,17 @@ public class ByteArrayOutputStream exten
return new String(toByteArray(), enc);
}
+ /**
+ * Gets the curent contents of this byte stream as a string
+ * using the specified encoding.
+ *
+ * @param charset the character encoding
+ * @return the string converted from the byte array
+ * @see java.io.ByteArrayOutputStream#toString(String)
+ * @since 2.5
+ */
+ public String toString(final Charset charset) {
+ return new String(toByteArray(), charset);
+ }
+
}