toString
Converts the buffer's contents into a string decoding bytes using the default charset. The length of the new String is a function of the charset, and hence may not be equal to the size of the buffer.
This method always replaces malformed-input and unmappable-character sequences with the default replacement string for the default charset. The CharsetDecoder class should be used when more control over the decoding process is required.
Return
String decoded from the buffer's contents.
Since
1.1
See also
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
{@snippet lang=java :
ByteArrayOutputStream b;Content copied to clipboardb.toString("UTF-8")Content copied to clipboard}
behaves in exactly the same way as the expression
{@snippet lang=java :
ByteArrayOutputStream b;Content copied to clipboardb.toString(StandardCharsets.UTF_8)Content copied to clipboard}
Return
String decoded from the buffer's contents.
Since
1.1
Parameters
the name of a supported charset
Throws
If the named charset is not supported
Converts the buffer's contents into a string by decoding the bytes using the specified charset. The length of the new String is a function of the charset, and hence may not be equal to the length of the byte array.
This method always replaces malformed-input and unmappable-character sequences with the charset's default replacement string. The [ ] class should be used when more control over the decoding process is required.
Return
String decoded from the buffer's contents.
Since
10
Parameters
the charset to be used to decode the bytes