Java – use Jackson to generate CSV without quotation marks
•
Java
I'm using Jackson CSV to generate CSV files, but I want references everywhere I can't find any information on apidoc
CSV writer
CsvMapper mapper = new CsvMapper(); //objects is a list CsvSchema schema = mapper.schemaFor(objects).withHeader(); schema = schema.withQuoteChar('\"');
Expected output
"name","value" "fieldName1","5" "fieldName2","2" "fieldName3","5"
Actual output
name,value fieldName1,5 fieldName2,2 fieldName3,5
POM xml
<dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-csv</artifactId> <version>2.6.3</version> </dependency>
If Jackson can't, I can try another library thank you.
Solution
Well, I finally found it by looking at apidoc and searching Google how I put them together
mapper.configure(CsvGenerator.Feature.ALWAYS_QUOTE_STRINGS,true);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码