下面的代码是将string转换为byte[]的代码
byte[] feedback;
feedback = "Your answer is correct and submit on time".getBytes();
但是我发现byte[]包含一系列数字,我如何转换回字符串“您的答案是正确的并按时提交”?
谢谢
最佳答案
String s = new String(feedback)
但请注意,getBytes()
和 new String()
都有采用编码的版本,在阅读 The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) 后,您真的、真的、真的应该使用它
关于java - 将字符串转换为 byte[] 并将 byte[] 转换为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10479948/