public static void writeFile(String fileName, String contents, boolean append) throws IOException {
try {
File file = new File(fileName);
BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(
new FileOutputStream(file, append), "GB2312"));
writer.write(contents);
writer.flush();
writer.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
BufferedWriter以append方式写入文件,指定编码
猜你喜欢
转载自blog.csdn.net/J_Jorey/article/details/102814850
今日推荐
周排行