'Generate CSV from entity based on columns reordering

How to achieve this concept based on generating CSV in case of:

  • Ignoring field that am not interested in (Could be obtain in OpenCSV based on MappingStrategy)
  • Order columns from the list My entity consist of 14 variables (id, number, surname...), for ignoring specific files i used new StatefulBeanToCsv.withMappingStrategyand it works properly, but additionaly i have f.e List of Fields/String that correspond to my entity, but generated csv should be exactly same ordered like list.

How to achieve this in OpenCSV, alternetively it could be any other lib


This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source