title: Java How to read unicode characters in socket?
body: <p>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:</p>
  
  <pre><code>    DataInputStream dis = new DataInputStream(is);
      int length = dis.readUnsignedShort();
      int flag = dis.readUnsignedShort();
  
      String content = "";
      int c;
      for (int i = 0; i &lt; length - 4; i++) {
          c = dis.read();
          content += (char) c;
      }
  </code></pre>
  
  <p>It only can read ascII.thxs for your helps!</p>