Archives: CSV

Java – Generate CSV from Java Bean using OpenCSV

Download OpenCSV: http://sourceforge.net/projects/opencsv/files/latest/download

OpenCSV is a free and open source library for reading and writing CSV files in Java. We need to have latest opencsv jar in classpath. Following example shows generating a CSV from java beans using opencsv.

Bean2CSV.java

Student.java

Output:

Generated CSV :
“name”,”age”
“Mayur”,”25″
“Vishal”,”26″