The server receives byte array as inputstream,and I wrapped the stream with DataInputStream.The first 2 bytes indicate the length of the byte array,and the second 2 bytes indicate a flag,and the next bytes consist of the content.My problem is the content contains unicode character which has 2 bytes.How can I read the unicode char ? My prev code is:
DataInputStream dis = new DataInputStream(is);
int length = dis.readUnsignedShort();
int flag = dis.readUnsignedShort();
String content = "";
int c;
for (int i = 0; i < length - 4; i++) {
c = dis.read();
content += (char) c;
}
It only can read ascII.thxs for your helps!