/**
* 写文件
*
* @param list
* @param dstPathName
*/
public static void writerText(List list, String dstPathName) {
File file = new File(dstPathName);
// 存在就覆盖,不存在就新建
if (file.exists()) {
file.delete();
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
} else {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
FileOutputStream out = new FileOutputStream(file, false);
for (int i = 0; i < list.size(); i++) {
out.write(list.get(i).toString().getBytes());
out.write("\n".getBytes());
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}