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

Creating CSV file in java

Ajoo Bar
Ranch Hand

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

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63532

What's the problem?

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link: http://aspose.com/file-tools
subject: Creating CSV file in java
It's not a secret anymore!