当CSVFormat的quoteMode设置为MINIMAL时,仅当值包含分隔符(,)或行分隔符' \ n'时才应引用该值。根据{{3}}。 但它确实引用了即使值包含哈希(#)。请参阅下面的示例代码
@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();
}
输出:sw:简单文字," ## 5 ##"
请提出一种方法,在这种情况下我可以避免引用。