/**
* CSV文件生成方法
* @param head表单头
* @param dataList表单内容
* @param outPutPath输出路径
* @param filename表单文件名
* @return
*/
public static File createCSVFile(List<Object> head, List<List<Object>> dataList,String outPutPath, String filename) {
File csvFile = null;
BufferedWriter csvWtriter = null;
try {
csvFile = new File(outPutPath + File.separator + filename + ".csv");
File parent = csvFile.getParentFile();
FileOutputStream fos = new FileOutputStream(csvFile);
// 写入bom头
byte[] uft8bom={(byte)0xef,(byte)0xbb,(byte)0xbf};
fos.write(uft8bom);
if (parent != null && !parent.exists()) {
parent.mkdirs();
}
csvFile.createNewFile();
// GB2312使正确读取分隔符",
java导出csv内容乱码
最新推荐文章于 2022-11-11 09:16:44 发布