try{
     String b = new String(a.getBytes("ISO-8859-1"));
                                       
} catch (UnsupportedEncodingException e) {
   System.out.println("Error:" + e.getMessage());
}

解决方案 »

  1.   

    String result = sb.toString();
    try{
    byte[] inputBytes = result.getBytes("8859_1");
    result=new String(inputBytes,"UTF-8");
    }
    catch(Exception e){}
    return result;
      

  2.   

    异常的意思好像你没明白比如说一个人走路可能出车祸但是一般情况下不会发生异常和这个差不多如果你把这句
    String b = new String(a.getBytes("ISO-8859-1"));
    写成
    String b = new String(a.getBytes("ISO-8859-1111"));
    肯定行不通
    就会转向异常处理
    如果你写对了
    就和你走路差不多了
      

  3.   

    我的目的是把一个string转换为unicode的字节流用于传输
    其中string中有中文也有英文
      

  4.   

    在方法声明上加上,throws java.io.UnsupportedEncodingException
    就行了。
      

  5.   

    我也正在找怎样把string转换为unicode的字节流!