问题描述
我想将我的文件csv像这样forma:
i would like to put my file csv like this forma:
我使用自己的Csv首选项:
i make my own Csv Preference like that:
private static final CsvPreference myPreference = new
CsvPreference.Builder('',';''\\\
')。build();
我想有一个头像User 2;Web Page
推荐答案
很难看到你没有一个完整的代码示例,而是从你的,我怀疑您要问如何总是引用 CSV字段。
It's hard to see what you're doing without a complete code example, but from your post on the Super CSV bug tracker, I suspect that you're asking how to always quote CSV fields.
有关 Super CSV网站的大量文档, a>如何配置自定义偏好设置 - 您之后的功能是引用模式。
There's extensive documentation on the Super CSV website on how to configure custom preferences - the feature you're after is the quote mode.
以下是使用 AlwaysQuote
引用模式,即使它不包含特殊字符,也会引用每个字段。
Here's an example of using the AlwaysQuote
quote mode, which quotes every field even if it doesn't contain special characters.
CsvPreference prefs = new CsvPreference.Builder('"',';',"\n")
.useQuoteMode(new AlwaysQuoteMode()).build();
ICsvListWriter writer = new CsvListWriter(new OutputStreamWriter(System.out),
prefs);
writer.writeHeader("User2", "Web Page");
writer.flush();
打印:
"User2";"Web Page"
这篇关于如何始终在超级CSV应用报价(转义)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!