UTF-8 in defaultStreamedContent for excel JSF2
<p>First I am converting an uploaded CSV into an XLS with this code.</p>

<pre><code>XSSFWorkbook workBook = new XSSFWorkbook();
    try {
        XSSFSheet sheet = workBook.createSheet("sheet1");
        String currentLine = null;
        int rowNum = 0;
        BufferedReader br = new BufferedReader(new InputStreamReader(dataFile.getInputstream(), "UTF-8"));
        while ((currentLine = br.readLine()) != null) {
            String str[] = currentLine.split(delimiter);
            XSSFRow currentRow = sheet.createRow(rowNum);
            rowNum++;
            for (int i = 0; i &lt; str.length; i++) {
                currentRow.createCell(i).setCellValue(str[i]);
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
</code></pre>

<p>I have this code to export (download) an xls.</p>

<pre><code>    try {
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        workbook.write(os);
        os.flush();
        os.close();
        byte[] data = os.toByteArray();
        InputStream is = new ByteArrayInputStream(data);
        return new DefaultStreamedContent(is, "application/xls", "non-active.xls");
    } catch (Exception e) {
        e.printStackTrace();
    }
</code></pre>

<p>the  problem is that a file that I have uploaded before looks like this.
<a href="https://i.stack.imgur.com/FiWz9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FiWz9.png" alt="enter image description here"></a></p>

<p>But later I am downloading this xls file with some possible errors added in the last column and it looks like this.</p>

<p><a href="https://i.stack.imgur.com/czNAs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/czNAs.png" alt="enter image description here"></a></p>

<p>Is there any possible solution for this issue? thank you in advance.</p>