can you use supercsv without a file
A fast, programmer-friendly, free CSV library for Java
Brought to you by:
jamesbassett,
kbg
I have a form that passes to a server multi-part form data and currently I am creating a file with the contents from the form in order to use supercsv. The data looks like this:
Is there a way to use supercsv without a file by doing it all in memory?
The reason I am asking about this is the client has the file and the server only needs the data not the file itself on the server.
Last edit: Colin McQueen 2013-01-30
Hi Colin, yes that's certainly possible. All of the Super CSV readers accept a Reader - in your case you'll need to use an InputStreamReader to read the CSV file from the posted form data (as I've suggested here).
If you're not already, I'd recommend using Apache Commons Fileupload which makes it really easy to obtain the InputStream for your uploaded file. BalusC has written an excellent overview on StackOverflow about this.
I'll look into getting an example onto the Super CSV website for the next release, but if you have any questions in the meantime, just ask :)
Thanks it worked using the InputStreamReader. Instead of using Apache Commons Fileupload, I am using in Servlet 3.0 the getPart method.
Last edit: Colin McQueen 2013-01-31