wood burning stoves*
The moose likes Java in General and the fly likes Creating CSV file in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Creating CSV file in java" Watch "Creating CSV file in java" New topic
Author

Creating CSV file in java

Ajoo Bar
Ranch Hand

Joined: Mar 28, 2011
Posts: 30
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

Joined: Jan 10, 2002
Posts: 60781
    
  65

What's the problem?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Creating CSV file in java
 
Similar Threads
Exception in parse method of opencsv
How to append data in CSV file using CSVWriter?
Problem creating CSV file with writeAll method of CSVWriter
Copy name of file from input to output
Take a csv file and generate another after modifications of the first