I am using opencsv to read a CSV file and it works well.
I am currently trying to retrieve details from a database using hibernate and want to write the values to a csv file.
I saw they have examples where you can use the column mapping strategy and tie the indexes of the csv to a java bean but opencsv doesnt have anything like that for writing to csv files.
Lets say I get a)a list of Employee objects b)a list of Employee objects with Address (another class, included as a java.util.set in the employee pojo)embedded within
How could I go about writing a csv file in this scenaro ?
Thanks for your response. Sadly, I wasn't able to figure out a column mapping strategy while reading from csv.
How could one write directly from a bean, when it is a simple pojo and also when it has nested pojos within itself ?
K. Tsang wrote:There's a BeanToCsv class in the OpenCSV API. Well you already figured out how to read bean to csv like:
Then to write
BTW, BeanToCsv is for ver 2.4 which isnt released yet.
I figured you wanted to write a list of list of beans then first how to produce a list of list of beans from reading then loop through it while writing.