commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1470213 - /commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java
Date Sat, 20 Apr 2013 18:06:24 GMT
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);
+    }
+
 }



Mime
View raw message