java 读写文件乱码问题
这样写,会出现乱码。原因是文件时gbk格式的,
BufferedReader br = new BufferedReader(new FileReader(indir)); BufferedWriter bw = new BufferedWriter(new FileWriter(outpath,true));
所以可以这样改:
//用fileinputstream才能解决读写文件乱码问题.视文件是gbk还是utf32而更改下面对应的字符。 BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(indir), "gbk")); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outpath), "gbk"));