HELLO打印在.tsv文件中的双引号中,因为'#'类似于"HELLO";。当它写入.tsv 时,我想删除双引号
电流输出->"#HELLO"
预期输出->#HELLO
try ( CSVPrinter printer = new CSVPrinter(new FileWriter("data.tsv"), CSVFormat.TDF))
{
printer.printRecord("#HELLO");
}catch (IOException ex) {
ex.printStackTrace();
}
您需要调整格式
CSVFormat.Builder.create(CSVFormat.TDF)
.withQuoteMode(QuoteMode.MINIMAL)
.build();
我将CSVCommons的版本更改为1.8,下面的代码对我有效…
CSVPrinter printer = new CSVPrinter(new FileWriter("data.tsv"), CSVFormat.TDF.withHeader("#default1", "default2").withEscape('"').withQuoteMode(QuoteMode.NONE)