1

Possible Duplicate:
Decode Base64 data in java

Thanks to everyone in advance,

I am aware of http://commons.apache.org/codec/api-release/org/apache/commons/codec/binary/Base64.html etc, can anyone point to me another option preferably one that does not require me to use external libraries.

Thanks,

Sam

3
  • 1
    You might find some answers here: stackoverflow.com/questions/469695/decode-base64-data-in-java Commented Jul 6, 2009 at 22:07
  • I think the link above provides you with a solution for Base64 but not QP... you could probably piece the information together from multiple answers on Stackoverflow. I don't believe this is a duplicate... Commented Jul 7, 2009 at 4:24
  • The thing to do in cases like this, is to ask a question that isn't already answered. So, post a question asking specifically for a library that'll en/decode quoted-printable. If you then accept Jon's, the combination of this and the linked question will provide a single solution for you or anyone wanting both. Commented Jul 9, 2009 at 1:44

4 Answers 4

1

Why not use one from iharder.net? It is fast and it is in public domain.

Sign up to request clarification or add additional context in comments.

2 Comments

Just curious: why would you recommend this over Commons Codec (which is, at least, more widely used)?
It is small and completely free of any licenses. Commons codec is more like an all-purpose library, and this tiny library does only one thing and does it very well.
0

migbase64 is the fastest (according to their benchmark).

Comments

0

Just wanted to answer this with some more information as people here seem to have missed your requirement for a utility for both Base64 and Quoted Printable.

Take a look at MimeUtility in Javamail here:

http://java.sun.com/products/javamail/javadocs/javax/mail/internet/MimeUtility.html

That provides encoding/decoding for both Base64 and Quoted Printable, amongst others, look at the decode method:

public static InputStream decode(InputStream is, String encoding) throws MessagingException 

Commons Codec provides similar functionality in the form of QCodec and Base64, but no main method that I know of. Hope that helps.

1 Comment

I too had the same requirement as the OP, but in my case, only for quoted-printable. I tried MimeUtility.decode(InputStream, encoding) but I'm finding that it doesn't have support for soft line breaks (= ). So decoded content is finally having soft line breaks included. Any idea/solution?
0

if you use Sun's jvm you can use sun.misc.BASE64Encoder/Decoder but it's not Open Source:

final BASE64Encoder encoder = new sun.misc.BASE64Encoder(); final String encodedString = encoder.encode( "whateveryouhaveinmind".getBytes() ); 

Comments