Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Writing to a CSV file

807605Sep 27 2007 — edited Sep 27 2007
Hi, I'm having some problems when I try to write the contents of an ArrayList to a CSV file. The file is generated and saved in my hard drive, but when I open it every row is stored in a single cell, instead of puting each value in a separate cell. My code is:
FileOutputStream fileOutput= new FileOutputStream("c:\\informe.csv");
PrintStream out = new PrintStream(fileOutput);
String separator = ","
			
response.setContentType("application/octet-stream");
response.setHeader( "Content-Disposition", "attachment; filename=\"" + fileOutput + "\";" );
			
out.print("Cell1" + separator);
out.print("Cell2" + separator);
out.print("Cell3 + separator);

out.close();
What am I doing wrong? Thanks a lot.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 25 2007
Added on Sep 27 2007
2 comments
729 views