FileOutputStream fout;
DataOutputStream dout;
try {

          lineString = din.readLine();
string_cn=new String(lineString.getBytes("ISO-8859-1"), "GBK");
lineString=string_cn;
System.out.println(lineString );
         dout.writeChars(lineString);
} catch (IOException e1) {
e1.printStackTrace();
}

解决方案 »

  1.   

    try
    {
    File f = new File("C:\\1.txt");
    FileOutputStream fout = new FileOutputStream(f);


    fout.write(this.t.getText().getBytes());

    fout.close();
    }
    catch(Exception er)
    {

    }看这个有用不?
      

  2.   

    string_cn=new String(lineString.getBytes("ISO-8859-1"), "GBK");
    这句不要或是改成:
    string_cn=new String(lineString.getBytes(), "GBK");
      

  3.   

    //多此一举
    //string_cn=new String(lineString.getBytes("ISO-8859-1"), "GBK"); //这样就可以了
    lineString = din.readLine();
    dout.writeChars(lineString);
      

  4.   

    使用writeUTF(String s)可以解决此问题?
      

  5.   

    public static void main(String args[]) {
        String s_FileName = "c:/test.txt";
        String s_DFileName = "c:/test1.txt";
        try {
          //定义输入流
          FileInputStream fis =
              new FileInputStream(s_FileName);
          BufferedInputStream bis =
              new BufferedInputStream(fis);
          //定义输出流
          FileOutputStream fos =
              new FileOutputStream(s_DFileName);
          BufferedOutputStream bos =
              new BufferedOutputStream(fos);
          DataOutputStream dos =
              new DataOutputStream(bos);
          int b;
          while ( (b = bis.read()) != -1) {
            dos.write(b);
          }
          bis.close();
          dos.close();
        }
        catch (IOException e) {
          System.err.println(e);
        }
      }
      

  6.   

    尽量不要使用DataInput/OutputStream写中文,经常有问题,实际上除非你确切需要writeInt这些操作,否则我都尽量使用String写
    我一般都使用BufferedWriter来写的,这样可以方便很多
      

  7.   

    呵呵,看了ChDw(米) 和kongkongye(飘在空中的汽水瓶) 的建议,然后用hl_longman(寒山之松!) 的方法修改程序,果然没问题了。Thanks Very Much!