csv用excel打开乱码问题.
//linux
if (System.getProperty("os.name").toLowerCase().indexOf("linux") >= 0) {
OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(writename), "UTF-8");
osw.write(new String(new byte[] { (byte) 0xEF, (byte) 0xBB,(byte) 0xBF }));
osw.write("\""+ CommonConsts.CONFERENCETITLE + "\""+ "," +"\""+ conferenceTitle +"\""+ "\r\n");
osw.write("\""+ CommonConsts.PLACE +"\"" + "," +"\""+ place + "\""+ "\r\n");
osw.write("\""+ CommonConsts.PARTICIPANTS + "\""+ "," +"\""+participants +"\""+ "\r\n");
osw.write("\""+ CommonConsts.SUBJECT + "\"" + "," +"\""+ subject +"\""+ "\r\n");
osw.write("\""+ CommonConsts.MEETSTARTTIME + "\"" + "," +"\""+ dateFormat2.format(dateFormat.parse(meetstartTime)) +"\""+ "\r\n");
osw.write("\""+ CommonConsts.MEETENDTIME + "\"" +"," +"\""+ dateFormat2.format(dateFormat.parse(meetendTime)) +"\""+ "\r\n");
osw.write("\""+ CommonConsts.SPEAKSTAETTIME+ "\""+ "," + "\""+ CommonConsts.SPEAKER +"\"" +"," + "\""+ CommonConsts.SPEAKEDITTEXT+"\"" +"\r\n");
for (TalkDataListDto talkDataListDto : talkDataList) {
osw.write("\""+dateFormat3.format(dateFormat.parse(talkDataListDto.getStartTime())) +"\""+ "," +"\""+ talkDataListDto.getTalker() +"\""+ "," +"\""+ talkDataListDto.getEditText() +"\""+ "\r\n");
}
osw.flush();
osw.close();
// windows
} else {
out = new BufferedWriter(new FileWriter(writename));
out.write("\""+ CommonConsts.CONFERENCETITLE + "\""+ "," +"\""+ conferenceTitle +"\""+ "\r\n");
out.write("\""+ CommonConsts.PLACE +"\"" + "," +"\""+ place + "\""+ "\r\n");
out.write("\""+ CommonConsts.PARTICIPANTS + "\""+ "," +"\""+participants +"\""+ "\r\n");
out.write("\""+ CommonConsts.SUBJECT + "\"" + "," +"\""+ subject +"\""+ "\r\n");
out.write("\""+ CommonConsts.MEETSTARTTIME + "\"" + "," +"\""+ dateFormat2.format(dateFormat.parse(meetstartTime)) +"\""+ "\r\n");
out.write("\""+ CommonConsts.MEETENDTIME + "\"" +"," +"\""+ dateFormat2.format(dateFormat.parse(meetendTime)) +"\""+ "\r\n");
out.write("\""+ CommonConsts.SPEAKSTAETTIME+ "\""+ "," + "\""+ CommonConsts.SPEAKER +"\"" +"," + "\""+ CommonConsts.SPEAKEDITTEXT+"\"" +"\r\n");
for (TalkDataListDto talkDataListDto : talkDataList) {
out.write("\""+dateFormat3.format(dateFormat.parse(talkDataListDto.getStartTime())) +"\""+ "," +"\""+ talkDataListDto.getTalker() +"\""+ "," +"\""+ talkDataListDto.getEditText() +"\""+ "\r\n");
}
out.flush();
out.close();
}