I've read about a dozen tutorials showing how to use OpenCSV and apache-commons-csv to parse CSV files. That's all nice and works for me. But one thing always catches my attention: OpenCSV has the CsvToBean
untility class which makes it so nice to convert CSV data to Java POJOs. I couldn't find the equivalent von CsvToBean
in apache-commons-csv
, though I think that the API of apache-commons-csv
is more clearly structured and thus it's more intuitive for me to use it.
How to comfortably convert a CSV record read with apache-commons-csv
to a bean? Sure, I can simply set every field manually. But that's not comfortable. It looks ugly and it's a code smell. When a field is added or removed it would result in one more place where I have to adjust the code, so it would increase the maintenance workload.
Idea: Can I use apache-commons-beanutils
in a similar fashion as CsvToBean to convert CSV data to Java POJOs, or what other way is there to do this?