更新时间:2022-04-13 15:37:37
您需要指定所需的编码,例如对于UTF-8
You need to specify the encoding you want e.g. for UTF-8
String doc = ....
byte[] bytes = doc.getBytes("UTF-8");
String doc2 = new String(bytes, "UTF-8");
doc
和 doc2
将是相同的。
要解码 byte []
,你需要知道使用了什么编码来确保它能正确解码。
To decode a byte[]
you need to know what encoding was used to be sure it will decode correctly.