当我们使用默认GBK编码保存文本时,下面2句代码其实是一样的效果,
new OutputStreamWriter(new FileOutputStream("out.txt"))
new FileWriter("out.txt")
当要求保存为其他编码比如UTF-8时,就要这样写
new OutputStreamWriter(new FileOutputStream("out.txt"),"UTF-8")
而如果要读取一个UTF-8编码的文本文件时,同样的要用
new InputStreamReader(new FileInputStream("in.txt"),"UTF-8");
而不能用new FileWriter("in.txt")