你说用getBytes("GBK")吗?试过了,不行

解决方案 »

  1.   

    下面的有方法你自己都试试:/**
     * <p>Title: 字符编码转换</p>
     * <p>Description: String Conversion 该类实现了各种字符编码之间的转换,包括Unicode、GB2312、BIG5</p>
     * <p>Copyright: Copyright (c) 2002</p>
     * <p>Company: TongJi NRDS</p>
     * @author fangcheng
     * @version 1.0
     */public class StrCvs{  /**
       * Unicode字符编码转换为GB2312字符编码
       * @param str 输入的字符串编码为Unicode
       * @return 输出的字符串编码为GB2312
       */
      public static String UnicodeToGB2312(String str){
        try{
          if(str == null || str.equals("")) return "";
          String newStr = null;
          newStr=new String(str.getBytes("ISO8859_1"),"gb2312");
          return newStr;
        }
        catch(Exception e){
          return str;
        }
      }  public static String GB2312ToUnicode(String str){
        try{
          if(str == null || str.equals("")) return "";
          String newStr = null;
          newStr = new String(str.getBytes("gb2312"),"ISO8859_1");
          return newStr;
        }
        catch(Exception e){
          return str;
        }
      }
      public static String UnicodeToGBK(String str){
        try{
          if(str == null || str.equals("")) return "";
          String newStr = null;
          newStr=new String(str.getBytes("ISO8859_1"),"GBK");
          return newStr;
        }
        catch(Exception e){
          return str;
        }
      }  public static String GBKToUnicode(String str){
        try{
          if(str == null || str.equals("")) return "";
          String newStr = null;
          newStr = new String(str.getBytes("GBK"),"ISO8859_1");
          return newStr;
        }
        catch(Exception e){
          return str;
        }
      }  public static String DBStrToUnicode(String str){
        try{
          if(str == null || str.equals("")) return "";
          String newStr = null;
          newStr = new String(str.getBytes(),"ISO8859_1");
          return newStr;
        }
        catch(Exception e){
          return str;
        }
      }  public static String ByteStreamToUnicode(byte[] byteStream){
        try{
          if(byteStream == null || byteStream.length == 0) return "";
          String newStr = null;
          newStr = new String(byteStream,"ISO8859_1");
          return newStr;
        }
        catch(Exception e){
          return byteStream.toString();
        }
      }}
      

  2.   


    newStr = new String(byteStream,"ISO8859_1");
    换成
    newStr = new String(byteStream,"UTF-8");
    实验一下
      

  3.   

    常见中文问题的解决方法: 1.JDK的中文问题: 
    不要使用DataInputStream与DataOutputStream,而要用 BufferedReader与BufferedWriter。2.Visual Age3.0的中文问题: 很简单。在Window-option菜单中给List、Source的选项 设置支持中文的字体就可以了。 3.数据库中文问题: Access + Javaodbc驱动程序不能支持中文(用getByte()也 不行),目前我还没有找到解决方法。 MySQl + Javaodbc驱动程序也有中文问题,目前我还没有找 到解决方法。 MySQl + mm.mysql.jdbc没有任何中文问题,但是建立数据 表,有中文输入的域,最好设成bianry,否则因为MySQL的 varchar、char、text等属性的域在查询时是不分大小写时, 这样中文查询时会出现问题。4.Jsp的中文问题。 setPropotery时的中文问题,使用URLDecoder.decode()进行 转换即可。