/**
* 字节转字符
* */
byte[] byte1 = "撒娇和id急啊的".getBytes("utf-8");
String str = new String(byte1);
System.out.println(str);
/**
* 字符转字节
* */
String str3 = "撒到货啊回答说";
byte[] bytes = str3.getBytes("utf-8");
for (int i = 0; i < bytes.length; i++) {
System.out.println(bytes[i]);
}
System.out.println(new String(bytes));
System.out.println(new String(bytes, 0, 6));
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交