commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Neidhart <thomas.neidh...@gmail.com>
Subject Re: [net] decoding quoted-printable?
Date Mon, 03 Feb 2014 18:31:53 GMT
On 02/03/2014 07:16 PM, Alex O'Ree wrote:
> Thanks for the quick reply.
> 
> I'm running into this now.
> 
> org.apache.commons.codec.DecoderException: Invalid URL encoding: not a
> valid digit (radix 16): 117
> 
> from the following code:
> 
> BufferedReader reader = (BufferedReader) pop3.retrieveMessage(msginfo.number);
> String line = "";
> StringBuilder sb = new StringBuilder();
> while ((line = reader.readLine()) != null) {
> String lower = line.toLowerCase(Locale.ENGLISH);
> sb.append(lower);
> }
> 
> String msg=sb.toString();
> byte[] bits;
> try {
> bits = org.apache.commons.codec.net.QuotedPrintableCodec.decodeQuotedPrintable(msg.getBytes("UTF8"));
> msg = new String(bits, "UTF8");
> } catch (Exception ex){//throw from here }
> 
> 
> Any suggestions?

It looks like you are trying to decode the whole message using the
QuotedPrintable decoder, which will of course not work, as not the whole
message is encoded like that, only the respective attachment.

There is yet another commons library, commons-email that helps you with
that. So you should parse your message with the MimeMessageParser from
there, get the attachment and decode it using the QuotedPrintableCodec.

btw. it is probably easier if you use java-mail together with
commons-email to do the job instead of using commons-net for this
purpose, but that's up to you.

Thomas


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message