生成的csv文件,设置为UTF-8格式,在windows上用EXCEL打开的话会乱码,在linux上用vim或者cat打开查看正常;设置为GBK格式的话,在windows上用EXCEL打开正常,但在linux上乱码
File file = new File(ospFileName);
OutputStream stream = new FileOutputStream(file);
stream.write(newbyte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF });
CsvWriter ospWriter = new CsvWriter(stream, ‘,‘, Charset.forName("UTF-8"));
String[] ospHead = new String[]{"No","Comment","server","method","param-exp","response","trace-id"};
ospWriter.writeRecord(ospHead);
这样的话,在windows上用EXCEL打开就不会是乱码,linux上也显示正常;