When CSVFormat's quoteMode is set to MINIMAL, it should quote the value only when the value contains a delimiter (,) or line separator '\n' according to the javadoc. But it does quoting even if the value contains hash (#). Please see below example code
@Test
public void testCSV() throws IOException {
String[] row = new String[]{"simple text","##5##"};
CSVFormat CSV_FORMAT = CSVFormat.DEFAULT.withRecordSeparator("\n").withQuoteMode(QuoteMode.MINIMAL);
StringWriter stringWriter = new StringWriter(1024);
CSVPrinter csvPrinter = new CSVPrinter(stringWriter, CSV_FORMAT);
csvPrinter.printRecord(row);
System.out.println("sw : " + stringWriter.getBuffer().toString());
csvPrinter.close();
stringWriter.close();
}
output : sw : simple text,"##5##"
Please suggest a way in which I can avoid quoting in such cases.