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

Community
  • 1
  • 1
  • 1
    You might find some answers here: http://stackoverflow.com/questions/469695/decode-base64-data-in-java – Jonik Jul 06 '09 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... – Jonathan Holloway Jul 07 '09 at 04: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. – Shog9 Jul 09 '09 at 01:44

4 Answers4

1

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

Malcolm
  • 41,014
  • 11
  • 68
  • 91
  • Just curious: why would you recommend this over Commons Codec (which is, at least, more widely used)? – Jonik Jul 06 '09 at 22:15
  • 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. – Malcolm Jul 06 '09 at 22:23
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() );
Community
  • 1
  • 1
diega
  • 603
  • 3
  • 9
0

migbase64 is the fastest (according to their benchmark).

RealHowTo
  • 34,977
  • 11
  • 70
  • 85
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.

Jonathan Holloway
  • 62,090
  • 32
  • 125
  • 150
  • 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? – Gnanam Dec 28 '11 at 08:18