package com.cmh.test;
public class Test {
public static void main(String[] args) {
String str = "123456789";
byte[] myByte = str.getBytes();
String byte2Str = myByte.toString();
StringBuffer sbuf = new StringBuffer(myByte.length);
if(myByte != null) {
for(int i = 0; i<myByte.length; i++) {
sbuf.append(String.valueOf((char)myByte[i]));
}
}
System.err.println("myByte==="+myByte);
System.err.println("byte2Str==="+byte2Str);
System.err.println("sbuf==="+sbuf);
}
}
运行结果:
myByte===[B@7d6e7d6e
byte2Str===[B@7d6e7d6e
sbuf===123456789