I'm currently working on a project that is done in Java, on google appengine. i have above 2000 records
Appengine does not allow files to be stored so any on-disk representation objects cannot be used. Some of these include the File class.
I want to write data and export it to a few csv files, the user to download it.
How may I do this without using any File classes? I'm not very experienced in file handling so I hope you guys can advise me.
Thanks.
Just generate the csv in memory using a StringBuffer and then use
StringBuffer.toString().getBytes()
to get a byte array which can then be sent to your output stream.For instance if using a servlet in GAE:
More information about GAE Servlets
More information about Content-Disposition
You can use OpenCSV library in Google App Engine.
You can store data in memory using byte arrays, stings and streams. For example,
Then in your Servlet you can serve your csv.toByteArray() as a stream. Some example is given here: Implementing a simple file download servlet.