I have this piece of code that adds a BOM UTF-8 to an outputstream . I need to add the BOM since Excel does not identify the UTF-8 encoding implicitly and hence french characters are shown as weird characters in excel .
try {
response.setContentType(getContentType(request, response));
response.setContentLength(downloadData.length);
ServletOutputStream os = response.getOutputStream();
//Specify the BOM (Byte order Mask) for UTF-8 so that Excel can identify the encoding and open it in the correct format
os.write(new byte[] { (byte)0xEF, (byte)0xBB, (byte)0xBF });
os.write(downloadData);
os.flush();
response.flushBuffer();
} catch (IOException e) {
logger.error(e);
}
However , when I output the outputstream to a file , the last character is not printed .
Any ideas why ?