public synchronized String toString (String charsetName) throws UnsupportedEncodingException

Converts the buffer's contents into a string by decoding the bytes using the named charset.

This method is equivalent to #toString(charset) that takes a charset.

An invocation of this method of the form

 
      ByteArrayOutputStream b = ...
      b.toString("UTF-8")
      
 
behaves in exactly the same way as the expression
 
      ByteArrayOutputStream b = ...
      b.toString(StandardCharsets.UTF_8)
      
 

Parameters:
charsetName    the name of a supported charset

Returns:  String decoded from the buffer's contents.

Exceptions:
UnsupportedEncodingException     If the named charset is not supported

Since:  1.1