import java.io.*;public class Test {
  File fileOut;
  BufferedWriter bWrite;  public Test() {
  }  public void writeFile() {
    fileOut = new File("c:/111.txt");
    String value = "我们都有一个家,名字叫中国!";
    try {
      bWrite = new BufferedWriter(new FileWriter(fileOut));
    }
    catch (IOException ex2) {
    }
    try {
      bWrite.write(value);
      bWrite.flush();
    }
    catch (IOException ex1) {
      System.out.println(ex1.toString());
    }
  }  public static void main(String[] args) {
    new Test().writeFile();
  }
}

解决方案 »

  1.   

    OutputStream是面向字节的流,写出去的是字节保存在文件里的,当然乱码
    应该用面向字符的流Writer,就像楼上那样~~
      

  2.   

    不行:<这个还不行
    DataOutputStream dout = new DataOutputStream(new FileOutputStream(saveTo));
    dout.writeChars(allMessages);
    dout.close();??????
    ??????
    ??????
    ??????
    ??????
    ??????
    ??????dsfds
    ??????dsfds
    ??????dsfds
    ??????dsfds
    ??????dsfds
    ??????dsfds
    ??????dsfds
    ??????dsfds
    ??????dsfds
    ??????dsfds
    ??????dsfds
    ??????dsfds
      

  3.   

    allMessages
    保存的TextArea的内容,
    是不是这个有关?