File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Genric CSV generator with field names in Prop/Map

 
Vijay Kumar koganti
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Lester Burnham
Rancher
Posts: 1337
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic