Exporting to csv for a POJO with List

1.7k Views Asked by At

I have a POJO with a List within it. I am trying to export the POJO to CSV data. Used jackson-dataformat-csv 2.6.3 library to do it. But failed to write the list values to it. Is there a way to do it.

Class ABC { 
String name;
List<DEF> list = new ArrayList();
//getters and setters
}

// Code to export or write to output stream

CsvMapper lCsvMapper = new CsvMapper();
CsvSchema lCsvSchema = lCsvMapper.schemaFor(ABC.class).withHeader();
//inputData is the ABC instance 
lCsvMapper.writer(lCsvSchema).writeValue(aInOutputStream, inputData);
0

There are 0 best solutions below