you codei think it's u wrong

解决方案 »

  1.   

    字符集问题,转换的时候要
    String.getBytes("字符集");
    具体的,要看代码
      

  2.   

    copy your code out here.
      

  3.   

    我说的字节数组是任意的,可能来自一个任意格式的文件,我已经使用程序证明了的确存在这样的情况。
    如下:
    public class test2 
    {
    public static void main(String[] args) 
    {
    System.out.println("Hello World!");
    for (int i1=0;i1<=255 ;i1++ )
    {
    for (int i2=0;i2<=255 ;i2++ )
    {
    byte bb[] = new byte[2] ;
    bb[0]=(byte)i1;
    bb[1]=(byte)i2;
    try{
    String ss=new String(bb,"GB2312");
    byte bb2[]=ss.getBytes("GB2312");
      //              if (!(bb[0]==bb2[0]&&bb[1]==bb2[1]))
       //             if(bb.length!=bb2.length)
    {
    System.out.println(i1+"    ***     "+i2+"  ***   "+ss+"     **    "+ss.length());
    }
    //
    }catch(Exception e){System.out.println(e);}
    }
    }
    }
    }
      

  4.   

    如果我没记错的话byte最大是127不是255