Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write CSV to String using opencsv without creating an actual file or a temp file

Tags:

java

file

opencsv

I'm trying to use the opencsv library to write a csv file. The restriction being that I do not want to create a file on the disk or even a temp file. Is there a way I can achieve it?

From what I looked, the constructor for CSVWriter requires a FileWriter object.

Thanks!

like image 382
LizardKing Avatar asked Jan 15 '14 16:01

LizardKing


1 Answers

Actually the constructor needs a Writer and you could provide a StringWriter to create a String.

like image 152
assylias Avatar answered Sep 30 '22 14:09

assylias