String array[] = String.split("&#x");
//then convert each string in array to integer values
//and combine these values into one byte array.

解决方案 »

  1.   

    sorry the "regex" should be ";" not "&#x".
      

  2.   

    用这个成吗?StringTokenizer,有没有拼错?我不知道
      

  3.   

    试试这个吧,应该可以的。
    String sArray[] = ss.split(";");
    byte   bArray[] = new byte[2 * sArray.length];
    for (i = 0 ; i < sArray.length; i++) {
        try {
            int tmp = Integer.parseInt(sArray[i].substring(3), 16);
            System.out.println(">>>>>int value is " + sArray[i].substring(3));
            bArray[i*2 + 1] = (byte)(tmp & 0xff); 
            bArray[i*2    ] = (byte)((tmp >> 8) & 0xff); 
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
    }
    System.out.println("convert to orginal String is " + new String(bArray));
      

  4.   

    原来的最后一句改成如下:try {
        System.out.println("convert to orginal String is " + new String(bArray, "UTF-16"));
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }————————————
    呵呵,还是编码方式的问题。