要求是:
例如
Name, Age, Location
"A","154","California"
"B","2","New York"
如何为写作创建此类SuperCSV首选项?
答案 0 :(得分:2)
使用以下自定义报价模式:
public class AllExceptHeaderQuoteMode implements QuoteMode {
@Override
public boolean quotesRequired(String csvColumn, CsvContext context, CsvPreference preference) {
if (1 == context.getLineNumber()) {
/*
* Case whene column names are written
*/
return false;
} else {
return true;
}
}
}
使用自定义报价模式:
CsvPreference preference = new CsvPreference.Builder(CsvPreference.STANDARD_PREFERENCE).useQuoteMode(new AllExceptHeaderQuoteMode()).build());