Sunday, April 6, 2014

CSV Tutorial : Convert CSV to Java Bean

Removed
In my project I needed to convert a CSV file to a list of beans (Person).
I first used JSEFA, but once tested, I have discovered that this framework have problem to convert fields to Double or Float.

I decided then to move to another framework, and finally I found the CSVeed framework which is quit nice and simple.



By default, the separator in CSVeed is ";" so make sure to change it if necessary.

@CsvFile(comment = '%', quote='\'', escape='\\', separator=',')
public Class Person{
...
}

Their web site have a comparison  with other frameworks which do also the conversion. For more details, have a look on their matrix.

No comments :

Post a Comment

Articles les plus consultés