String text = ....;
String convert = new String(text.getBytes("ISO-8859-1"), "GBK");
就可以了

解决方案 »

  1.   

    这个很麻烦哦
    不过你给出了中文后稍微好一点举个例子
    "\311\317\264\253\316\304\274\376"
    读进来\311
    把311转为byte b
    得到byte[] ch
    然后new String(ch,"ISO8859_1")写出去的时候getByte("GBK");
      

  2.   

    源代码如下:import java.io.UnsupportedEncodingException;public class Convert{
    public static String toGBK(String source){
    String GBKstr = "";
    try{
    GBKstr = new String(source.getBytes("iso-8859-1"),"GBK");
    }catch(UnsupportedEncodingException e){
    System.out.println("源字符串不是 iso-8859-1");
    }
    return GBKstr;
    }

    public static void main(String[] args){
    String str1 = "\311\317\264\253\316\304\274\376";
    String str2 = "\315\250\320\305\263\314\320\362\325\375\303\246";
    String str3 = "\262\273\304\334\275\370\320\320\311\317\264\253\265\304\267\376\316\361";

    System.out.println("str1 = " + toGBK(str1));
    System.out.println("str2 = " + toGBK(str2));
    System.out.println("str3 = " + toGBK(str3));
    }
    }运行结果是:
    str1 = 上传文件
    str2 = 通信程序正忙
    str3 = 不能进行上传的服务
    Press any key to continue...
      

  3.   

    String str = new String(text.getBytes("ISO-8859-1"), "GBK");就行了
      

  4.   

    对,是有这个问题。
    我用FileInputStream从txt文件中读出byte[] buf来,再构建成String都不行。
    不知道怎么办了。
      

  5.   

    我一般这么用
    String str = new String(text.getBytes("ISO-8859-1"), "GBK");
      

  6.   

    我也这么用
    String str = new String(text.getBytes("ISO-8859-1"), "GBK");