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

LizardKing picture LizardKing · Jan 15, 2014 · Viewed 8.1k times · Source

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!

Answer

assylias picture assylias · Jan 15, 2014

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