你用
byte[] strAsByte;
String str = new String(strAsByte,"GB2312");
试试
或者
byte[] strAsByte;
String str = new String(strAsByte,"ISO-8859");
另外你去的数据流的时候最好用字节流别用字符流(就是最好用Stream,而不要用Reader或Writer)

解决方案 »

  1.   

    你把byte[]中的每一个打出来看看它到底是什么格式,在做处理吧
      

  2.   

    byte[] strAsByte;
    String str = new String(strAsByte,"GB2312");
    或者
    byte[] strAsByte;
    String str = new String(strAsByte,"GBK");
    或者
    byte[] strAsByte;
    String str = new String(strAsByte,"ISO-8859-1");
      

  3.   

    先确保发送的数据和你收到的数据要一样
    可以打出前几个byte看看是否跟c++编码时的byte一样
    如果一样,那么在java这边构造回字符串时用:new String(String str, String encoding);是没有问题的!!!
      

  4.   

    看看它是不是unicode(如:‘世界杯’的gb2312byte[]是-54-64-67-25-79-83unicode数据:-1-2227876117111103)
      

  5.   

    java的unicode和现行的unicode3有一定的差别
      

  6.   

    C++过来的……试试这个:"UnicodeLittleUned"或者在C++端就转换成Unicode
      

  7.   

    是这样用
    String ab  = new String(byte[],"UnicodeLittleUned");
      

  8.   

    另外这个UnicodeLittleUned是应该通过System.getProperty("sun.io.unicode.encoding");得到的