diff --git a/iped-viewers/iped-viewers-impl/src/main/java/dpf/sp/gpinf/indexer/ui/fileViewer/frames/EmailViewer.java b/iped-viewers/iped-viewers-impl/src/main/java/dpf/sp/gpinf/indexer/ui/fileViewer/frames/EmailViewer.java index 804188e24d..e797110013 100644 --- a/iped-viewers/iped-viewers-impl/src/main/java/dpf/sp/gpinf/indexer/ui/fileViewer/frames/EmailViewer.java +++ b/iped-viewers/iped-viewers-impl/src/main/java/dpf/sp/gpinf/indexer/ui/fileViewer/frames/EmailViewer.java @@ -211,8 +211,7 @@ private String decodeIfUtf8(String value) { return value; } - private void createHeader(OutputStream outStream) throws IOException { - OutputStreamWriter writer = new OutputStreamWriter(outStream, bodyCharset); + private void createHeader(OutputStreamWriter writer) throws IOException { writer.write(""); //$NON-NLS-1$ writer.write("
"); //$NON-NLS-1$ @@ -379,14 +378,20 @@ public void body(BodyDescriptor body, InputStream is) throws MimeException, IOEx public void endMessage() throws MimeException { try { - previewFile = File.createTempFile("message", ".html"); //$NON-NLS-1$ //$NON-NLS-2$ + previewFile = File.createTempFile("message", ".html"); previewFile.deleteOnExit(); - OutputStream outStream = new BufferedOutputStream(new FileOutputStream(previewFile)); - createHeader(outStream); + } catch (IOException e1) { + throw new RuntimeException(e1); + } + + Charset charset = Charset.forName(bodyCharset); + try (OutputStream outStream = new BufferedOutputStream(new FileOutputStream(previewFile)); + OutputStreamWriter writer = new OutputStreamWriter(outStream, charset)) { + + createHeader(writer); Set