在java中使用apache commons编写CSV时包含双引号

在java中使用apache commons编写CSV时包含双引号,java,csv,apache-commons-csv,Java,Csv,Apache Commons Csv,我正在使用ApacheCommonsCSV来编写CSV文件。我想坚持这个图书馆。在编写csv文件时,在生成的文件的第一列中,它包含双引号作为引号字符,其他列按预期生成 我真的想去掉这里的双引号。请查找以下相同的代码 CSVFormat format = CSVFormat.DEFAULT; FileWriter fw = new FileWriter("Temp.csv"); CSVPrinter printer = new CSVPrinter(fw, format); String[] t

我正在使用ApacheCommonsCSV来编写CSV文件。我想坚持这个图书馆。在编写csv文件时,在生成的文件的第一列中,它包含双引号作为引号字符,其他列按预期生成

我真的想去掉这里的双引号。请查找以下相同的代码

CSVFormat format = CSVFormat.DEFAULT;
FileWriter fw = new FileWriter("Temp.csv");
CSVPrinter printer = new CSVPrinter(fw, format);

String[] temp = new String[4];

for(int i=0; i<4; i++) {
    if(i==1)
        temp[0] = "#";
    else
        temp[0] = "";
    temp[1] = "hello" + (i+1);
    temp[2] = "";
    temp[3] = "test";

    Object[] temp1 = temp[]
    printer.printRecord(temp1);
}

fw.close();
printer.close();
CSVFormat format=CSVFormat.DEFAULT;
FileWriter fw=新的FileWriter(“临时csv”);
CSVPrinter打印机=新的CSVPrinter(fw,格式);
字符串[]临时=新字符串[4];

对于(int i=0;i这是一个已知的问题。您可以在apache commons csv问题跟踪器中投票:


在LAS问题跟踪中提到,请尝试将CSVFormat设置为以下值:


final CSVFormat csvFileFormat=CSVFormat.DEFAULT.withEscape('\\')。withQuoteMode(QuoteMode.NONE)

我知道这已经5年了,但它在第一个字段中输出了一个空字符串。这就是为什么有两个引号的原因。有趣的是,当我开始使用CSV文件时,所有文本字段都被引号包围。也许我很厌倦,因为当时我主要在Microsoft领域工作。现在我回来了,看起来生成CSV的东西要宽松得多。在1.5版本上不起作用,你知道这是哪个版本吗?