csv to bean , excluding the values not included in csv header java

otto07

New Member
I'm trying to write a code where a csv content is converted to a bean. This is how my code looks like\[code\]final String TEMPLATE_FILE="addresses.csv"; CSVReader template = new CSVReader(new FileReader(TEMPLATE_FILE)); String [] header = template.readNext(); ColumnPositionMappingStrategy strat = new ColumnPositionMappingStrategy(); strat.setType(PersonEx.class); strat.setColumnMapping(header); CsvToBean csv = new CsvToBean(); List list = csv.parse(strat, template);\[/code\]In here if a particular attribute of PersonEx.class is missing in the csvHeader that attribute is ascribed as null. Is there a way, I can ignore this and only create a bean of values present in the header?
 
Back
Top