一个生成CSV文件的简单例子
List<String> resultLst = new ArrayList<String>();
try {
FileWriter fw = new FileWriter("D:\\resultCsv.csv");
fw.write("开始时间,结束时间,国外如流量,过外出流量,国内入流量,国内出流量,使用的IP,本次金额,退出类型,联网类型\r\n");
for (int i = 0; i < resultLst.size(); i++) {
fw.write(resultLst.get(i) + ",");
BigDecimal count = new BigDecimal(i+1);
if(count.remainder(new BigDecimal(10)).compareTo(new BigDecimal(0)) == 0) {
fw.write("\r\n");
}
}
fw.close();
} catch (IOException e) {
e.printStackTrace();
}