This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes Writing CSV file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Writing CSV file" Watch "Writing CSV file" New topic

Writing CSV file

Mike Jeya
Ranch Hand

Joined: Apr 15, 2004
Posts: 54
we need to create the CSV file . problem is some column value have comma in it, because of which the file format is changed.
can you please let me know the procedure to take care of comma values too,

RandomAccessFile raf = new RandomAccessFile(file, "rw");;
raf.writeBytes(new StringBuffer(strUID+","

please advise me.....
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
You need to enclose all cells contents by quotes, so that they look like this:

There are other characters that need to be treated especially (like doubles quotes and newlines), so you may be better off using one of the readily available CSV libraries. The lists several.
Rajasekhar Pentakota
Ranch Hand

Joined: Aug 28, 2007
Posts: 38

I agree. Here's the link:
subject: Writing CSV file
jQuery in Action, 3rd edition