how to avoid use of toString().getBytes("UTF-8") to avoid OOM error? Is there any better approach to convert to byte[] from StringWriter?

I have reporting web application which is generates report. Application gets data from DB and stores data into StringWriter object. now I have to get this data in byte array format to create csv file and send it to browser.

below is the code snipet

return new FileTransfer(fileName, reportType.getMimeType(),

new ByteArrayInputStream(generateCSV(reportType, grid, new DataList(), params).toString().getBytes("UTF-8")));

where generateCSV returns StringWriter object then to convert it into byte array I am calling toString and then getBytes() funtion.

below is the generateCSV method looks like

StringWriter generateCSV(ReportType reportType, GridConfig grid, DataList dataList, String params) {......}

The problem is that...

Read More »

By: StackOverFlow - 6 days ago

Related Posts