看String的两个构造函数 String(byte[] bytes, int offset, int length, String charsetName) Constructs a new String by decoding the specified subarray of bytes using the specified charset. String(byte[] bytes, String charsetName) Constructs a new String by decoding
public String(); public String(String str); public String(StringBuffer buffer); public String(char ch[]); public String(byte b[]);
public static String toString(byte[] a) { if (a == null) return "null"; if (a.length == 0) return "[]";
StringBuilder buf = new StringBuilder(); buf.append('['); buf.append(a[0]);
for (int i = 1; i < a.length; i++) { buf.append(", "); buf.append(a[i]); }
String s = new String(byte[] b);
String(byte[] bytes, int offset, int length, String charsetName)
Constructs a new String by decoding the specified subarray of bytes using the specified charset.
String(byte[] bytes, String charsetName)
Constructs a new String by decoding
public String(String str);
public String(StringBuffer buffer);
public String(char ch[]);
public String(byte b[]);
if (a == null)
return "null";
if (a.length == 0)
return "[]";
StringBuilder buf = new StringBuilder();
buf.append('[');
buf.append(a[0]);
for (int i = 1; i < a.length; i++) {
buf.append(", ");
buf.append(a[i]);
}
buf.append("]");
return buf.toString();
}