commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex O'Ree" <>
Subject [net] decoding quoted-printable?
Date Mon, 03 Feb 2014 16:48:48 GMT
I'm sending an email to a local mail server (hmail) using the standard
javax.mail api. Here's a snippit

MimeMessage message = new MimeMessage(session);
InternetAddress address = new InternetAddress("receiver@local.domain");
Address[] to = {address};
message.setRecipients(RecipientType.TO, to);
String subscriptionResultXML = ""; //some raw xml goes here
message.setContent(subscriptionResultXML, "text/xml; charset=UTF-8;");

When it sends, it appears to chop up the xml into roughly 80 chars,
adding a =\n (line break). The message is also flagged with
"quoted-printable" encoding with the following headers:
MIME-Version: 1.0
Content-Type: text/xml; charset=UTF-8;
Content-Transfer-Encoding: quoted-printable

On the receiving side, I'm using the commons POP3 Client and I've been
struggling with how to decode the text. Basically, I need to remove
the =\n line breaks and end up with just the XML. I've tried using
BufferedReader reader = (BufferedReader) pop3.retrieveMessage(msginfo.number);
String line = "";
StringBuilder sb = new StringBuilder();
while ((line = reader.readLine()) != null) {
          String lower = line.toLowerCase(Locale.ENGLISH);

String msg=sb.toString();
InputStream is = new ByteArrayInputStream(msg.getBytes("UTF8"));
 InputStream decode = javax.mail.internet.MimeUtility.decode(is,
StringWriter writer = new StringWriter();
IOUtils.copy(decode, writer, "UTF8");
msg = writer.toString();

However, I still end up with a string that includes the line encoding.
Interestingly enough, outlook seems to decode it just fine and renders
the xml as an attachment which is valid XML. Any ideas?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message