I am using Jackson CSV to generate a CSV file, but I want to have the quote everywhere. I couldn't find any information on the 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 it's not possible with Jackson I am open to try another library. Thanks.
Ok I finally found it by looking at the ApiDoc and searching with Google on how I could put it all together. Here the solution to enabling the feature that I wanted:
mapper.configure(CsvGenerator.Feature.ALWAYS_QUOTE_STRINGS, true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With