Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating CSV file in java

 
Ajoo Bar
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a requirement to create a CSV file using this open source package au.com.bytecode.opencsv.CSVWriter;

Here is what my requirement is:
1) Retrieve User information from database. I get it in the Java Bean object:- I have done this part here is the sample code
List<BusinessUser> users = usedao.getUsers();
//CSVWriter writer = new CSVWriter(new Writer("path"), "|" );
if (users != null && users.size() > 1) {
Iterator<BusinessUser> it = users.iterator();
while (it.hasNext()){
BusinessUser bu = it.next();
// Test
String loginName = bu.getLoginName();
String firstName = bu.getFistName();
String lastName = bu.getLastName();

}

}
2) public void createHeaderToCSVFile(){
// Header name are" Login Name", "First Name" "Last Name".... there are more colums, but to make it easy for the post I have included only 3 columns
}

3) public void writeRowToCSVFile(){

}

Can someone please help me on this. I need to use | delimeter.

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the problem?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic