Java 读写GBK编码的文件
以GBK编码某个读写文件 读入: BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("a.txt"), Charset.forName("GBK"))); String str = br.readLine(); br.close(); 写出: BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("a.txt"), Charset.forName("GBK"))); bw.write("hello"); bw.flush(); bw.close(); 使用try-with-resource语法确保close