Search code examples
javaopencsv

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?


Solution

  • Put the annotation

     @CsvBindByPosition(position = 0)
    

    On the bean being serialised.