【问题标题】:how to configure tab as delimited in using CSVFormat?如何将选项卡配置为使用 CSVFormat 分隔?
【发布时间】:2018-05-15 16:55:54
【问题描述】:

我正在使用 org.apache.commons.csv.CSVFormat 来输出 csv 文件。我的配置如下:

String[]   HEADERS     = {"sku", "question", "annotation", "answer", "url", "answerType"};
CSVFormat  csvInFormat = CSVFormat.DEFAULT.withHeader(HEADERS);
CSVPrinter printer     = new CSVPrinter(bw, csvInFormat);

这将打印以逗号分隔的 csv。如何输出以tab为分隔符的内容?

【问题讨论】:

    标签: java csv


    【解决方案1】:

    要将制表符用作分隔符,请使用CSVFormat.TDF

    CSVFormat  csvInFormat = CSVFormat.TDF.withHeader(HEADERS);
    

    阅读更多关于这个CSVFormat.TDF config here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-08
      • 2019-04-07
      • 1970-01-01
      • 1970-01-01
      • 2016-04-12
      • 1970-01-01
      • 1970-01-01
      • 2020-06-16
      相关资源
      最近更新 更多