• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Genric CSV generator with field names in Prop/Map

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am planning to write a generic CSV generator method that would take ObjectList and Map/properties file with all the pojo fields info. The method then has to
create a csv file by iterating through the list of objects and based on the Map/Properties file fetch all the field values(Fields are defined in the Properties file)
for each of object and create csv file at the end.
For Ex:
1. List of Employee Pojo Objects
2. Properties file with some of the fields from Employee pojo say EmpName,EmpID
3. Resultant CSV file :
vijay,12
kumar,34
ravi,45

What i am looking for is some pointers on what is the best way to do it and is there some thing that is readily available opensource that i can use/extend it.I wanted
to follow this approach so that if tomorrow some new fields has to be added i dont have to touch my code just update my properties file and it should work.

regards,
vijay
 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The http://faq.javaranch.com/java/AccessingFileFormats page lists several CSV-generating libraries. CSVBeans in particular sounds as if it does something like what you propose.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic