// 写文件UTF-8格式 写一行
public static void writerTxtFile(String filePath, String text) {
OutputStreamWriter fs;
try {
fs = new OutputStreamWriter(new FileOutputStream(filePath, true), "UTF-8");
fs.write(text + "\n");
fs.flush();
fs.close();
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
// 写文件UTF-8格式 写一行
public static void writerStringBuffer(String filePath, StringBuffer text) {
OutputStreamWriter fs;
try {
fs = new OutputStreamWriter(new FileOutputStream(filePath, true), "UTF-8");
fs.write(text + "\n");
fs.flush();
fs.close();
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
// 写文件
public static void writerTxtFile(String filePath, List<String> list) {
OutputStreamWriter fs;
try {
fs = new OutputStreamWriter(new FileOutputStream(filePath, true), "UTF-8");
for(int i=0; i<list.size(); i++){
fs.write(list.get(i) + "\n");
}
fs.flush();
fs.close();
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}