opencsv一个简单的CSV解析Java包。它封装了CSV格式文件的输出和读入,可以自动处理CSV格式中的特殊字符。
示例
File tempFile = new File("./Group" + querytime + ".csv");
OutputStreamWriter osw = null;
try {
osw = new OutputStreamWriter( new FileOutputStream(tempFile),"GB18030" );
} catch (Exception e1) {
e1.printStackTrace();
}
try {
CSVWriter writer = new CSVWriter(osw);
for ( int i = 0; i < data. length; i++) {
writer.writeNext(data[i]);
}
writer.close();
} catch (Exception e) {
logger.info( "getgroupCSV", e.getLocalizedMessage());
}