I am trying to decode an outlook .MSG file to a text file, using Apache POI classes.
Everything works fine, except for the println
method of PrintWriter
: it doesn´t create a new line.
It just concatenates every sentence directly one after another. The result of the code snippet below is
"De: textPara: " iso "De: " "Para: "
I tried the code on several machines: it works on my local tomcat instalation (Windows machine), but fails on a tomcat or Weblogic instalation on a Solaris platform. I thought it had something to do with the encoding algorithm, so I used PrintStream
in stead of Printwriter
, indicating the encoding ISO-8859-1, but no luck neither.
Any idea?
try {
byte [] msgByte = Base64.decodeBase64(msgBase64);
InputStream inputMsg = new ByteArrayInputStream(msgByte);
msg = new MAPIMessage(inputMsg);
/* 1. Transform MSG to TXT. */
try {
txtOut = new PrintWriter(outputMsg);
try {
String displayFrom = msg.getDisplayFrom();
txtOut.println("De: "+displayFrom);
} catch (ChunkNotFoundException e) {
_logger.info("Error extrayendo displayFrom: "+e);
}
try {
String displayTo = msg.getDisplayTo();
txtOut.println("Para: "+displayTo);
} catch (ChunkNotFoundException e) {
_logger.info("Error extrayendo displayTo: "+e);
}
} finally {
if(txtOut != null) {
txtOut.close();}
else {
_logger.error("No se ha podido parsear el mensaje.");
}
}