java中如何将byte数组内容转换为字符串?

rt

public class ByteTest {
public static void main(String[] args) {
String str = "Hello world!";
// string转byte
byte[] bs = str.getBytes();
System.out.println(Arrays.toString(bs));

// byte转string
String str2 = new String(bs);
System.out.println(str2);
}
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2009-11-14
new String(byte[])
new String(byte[],起始下标,字节数)
第2个回答  2009-11-14
自己查api吧,用的多了就记住了

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网