通过流获取到 char[] ; 将char[] 转换为String;这个过程中怎么指定其编码格式呢。
官方有api,,char[] 转string的,,,题主想指定编码,就得先转string,再转byte,在制定编码转回来
因为char字符,自带编码格式,字节的话没编码,,字符自己就有编码,,,有问题还可以追问
【官方api】
public String(char value[], int offset, int count) {
if (offset < 0) {
throw new StringIndexOutOfBoundsException(offset);
}
if (count <= 0) {
if (count < 0) {
throw new StringIndexOutOfBoundsException(count);
}
if (offset <= value.length) {
this.value = "".value;
return;
}
}
// Note: offset or count might be near -1>>>1.
if (offset > value.length - count) {
throw new StringIndexOutOfBoundsException(offset + count);
}
this.value = Arrays.copyOfRange(value, offset, offset+count);
}
http://www.cnblogs.com/fuzhaoyang56/archive/2013/05/24/3096471.html
char[] charArray = new char[]{'你','b'};
System.out.println(new String(charArray));
char代表一个自费不用制定编码了