简体   繁体   中英

When writing a file produced by opencsv in java how do I create a file with no heading?

I'm writing using StatefulBeanToCsvBulder. The file format requires that the header have file meta-data, rather than columns. There are 3 bean types.

StatefulBeanToCsv headerCsvBuilder = new StatefulBeanToCsvBuilder(writer)
            .withThrowExceptions(false)
            .withOrderedResults(false)
            .build();
    headerCsvBuilder.write(outputHeader);

StatefulBeanToCsv csvBuilderTransactions = new StatefulBeanToCsvBuilder(writer)
            .withThrowExceptions(false)
            .withOrderedResults(false)
            .build();
    csvBuilderTransactions.write(samplesList);

How do I output this without printing a header each time?

Put the annotation

 @CsvBindByPosition(position = 0)

On the bean being serialised.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM