编辑代码

import java.io.*;

public class FileStreamTeat2 {
	public static void main(String[] args) throws IOException{

        File f = new File("a.txt");

        FileOutputStream fop = new FileOutputStream(f);
        OutputStreamWriter w = new OutputStreamWriter(fop,"UTF-8");

        w.append("输入中文");//写入到缓冲区
        w.append("\r\n");//换行
        w.append("English");
        w.close();
        fop.close();//关闭输出流,释放系统资源


        FileInputStream fip = new FileInputStream(f);
        InputStreamReader r = new InputStreamReader(fip,"UTF-8");

        StringBuffer sb = new StringBuffer();
        while(r.ready()){
            sb.append((char)r.read());//转成char加到StringBuffere对象sb中;
        }
        System.out.println(sb.toString());
        r.close();
        fip.close();

		System.out.println(".");
	}
}