使用具有以下maven依赖关系的Apache CSV。我得到了预期的结果。
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.2</version>
</dependency>
和代码
String test = CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true)
.format(""," "," Test1","Test2"," Test3 ");
System.out.println(test);
实际输出
""," "," Test1",Test2," Test3 "
预期产出
"","","Test1","Test2","Test3"
输出错误: 1.没有修剪额外的空间。 2. Test2打印没有引号是正常的行为。