String s = "大家好";
    try
    {
      s = new String(s.getBytes(), "ISO-8859-1");
    }
    catch(Exception e){}
    System.out.print(s.length());

解决方案 »

  1.   

    String str="大家好";
    byte[] b=str.getBytes();
    System.out.println(b.length);
    System.out.println(new String(b,0,2));
      

  2.   

    如何判断String里面存的英文还是中文?
      

  3.   

    不对啊,运行完
    new String(s.getBytes(), "ISO-8859-1");
    以后,再显示s,其中的中文就变成乱码了,怎么再转回来啊?
      

  4.   

    new String(s.getBytes("8859-1"), "GB2312");