生成csv文件

String filepass= "c:/tmp/aa.csv";
try (BufferedWriter output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filepass),"UTF-8")))
{
StringBuffer result = new StringBuffer();


result = new StringBuffer();


result.append("\"");
result.append("aa");
result.append("\"");
result.append(",");


result.append("\"");
result.append("bb");
result.append("\"");
result.append("");


output.write(result.toString());
output.write("\r\n");


//new line
result = new StringBuffer();
result.append("\"");
result.append("cc");
result.append("\"");
result.append(",");


result.append("\"");
result.append("dd");
result.append("\"");
result.append("");


output.write(result.toString());
output.write("\r\n");


//close
output.close();


} catch (IOException e) {


}

猜你喜欢

转载自blog.csdn.net/songyongchen/article/details/78841901