I'm using openCSV to generate CSV file and OutputStreamWriter to attach that file to http response.
The biggest issue here is that for example '€' in downloaded CSV file is '€'. Obviously the encoding is wrong but I've set it to 'UTF-8'. Additionally I've set the encoding in pom.xml to 'UTF-8'.
response.setHeader("Content-Disposition", "attachment; filename=" + filename + ".csv");
response.setContentType(BulkListExportConstants.CSV_CONTENT_TYPE);
OutputStreamWriter osw = new OutputStreamWriter(response.getOutputStream(), "UTF-8");
List<String[]> result = iSmsExportService.csvExport(columnNames);
CSVWriter csvWriter = new CSVWriter(osw, BulkListSharedConstants.CSV_SEPARATOR);
csvWriter.writeAll(result);
csvWriter.flush();
csvWriter.close();
osw.flush();
osw.close();
Any suggestions?