This tutorial demonstrates how to convert a ·byte[]· to String.
Encoding this String into a sequence of bytes using the given Charset, storing the result into a new byte array.
byte[] byteArray =
"this is a string".getBytes(StandardCharsets.UTF_8);
Constructs a new String by decoding the specified array of 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.
String converted =
new String(byteArray, StandardCharsets.UTF_8);
注意: 解码和编码的字符集要一直。