Skip to content

Commit 4f84528

Browse files
committed
Add support for Charset encoding (already supports String)
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1470213 13f79535-47bb-0310-9956-ffa450edef68
1 parent efc754a commit 4f84528

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,4 +375,17 @@ public String toString(final String enc) throws UnsupportedEncodingException {
375375
return new String(toByteArray(), enc);
376376
}
377377

378+
/**
379+
* Gets the curent contents of this byte stream as a string
380+
* using the specified encoding.
381+
*
382+
* @param charset the character encoding
383+
* @return the string converted from the byte array
384+
* @see java.io.ByteArrayOutputStream#toString(String)
385+
* @since 2.5
386+
*/
387+
public String toString(final Charset charset) {
388+
return new String(toByteArray(), charset);
389+
}
390+
378391
}

0 commit comments

Comments
 (0)