/**
* 将数据逐行写入文件
*
* @param filePath
* @param content
*/
public static void contentToTxt(String filePath, String content) {
BufferedWriter out = null;
try {
File file = new File(filePath);
if (!file.exists()) {
file.createNewFile();// 不存在则创建
}
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true)));
out.write(content);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}