gpt4 book ai didi

java - 将字符串转换为 byte[] 并将 byte[] 转换为字符串

转载 作者:行者123 更新时间:2023-12-01 22:11:20 25 4
gpt4 key购买 nike

下面的代码是将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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com