Java中byte怎么转化为String

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_30060779/article/details/79570652

string转化为byte[]数组

String str = "abcd";
byte[] bs = str.getBytes();

byte[]数组转化为string字符串

/*String str1 = "abcd";
byte[] bs1 = str1.getBytes();*/
byte[] bs1 = {97,98,100};
String s = new String(bs1);

设置格式

byte[] srtbyte = {97,98,98};
String res = new String(srtbyte,"UTF-8");	

猜你喜欢

转载自blog.csdn.net/qq_30060779/article/details/79570652