kostja kostja - 1 year ago 169
Java Question

Base64 decoding using JDK6 only

This question with regard to JDK 5 says, there is no implementation provided with JDK 5, but JDK 6 is supposed to have a


As far as I can tell though, this class is not provided with the JDK and I was not able to find any other similar classes in it

So, what is the situation like with JDK6?

I am aware of numerous implementations out there like the Commons and the JBoss ones, but we have a restrictive 3rd party lib policy, so I am trying to avoid reinventing the wheel.

Answer Source

No, the situation didn't change between Java 5 and Java 6.

Unfortunately there is no official Base64 implementation in the Java SE platform. @bestsss has shown that there is in fact a (well-hidden) Base64 implementation in Java SE 6 (see his answer for more detail).

The Sun JDK ships with this class (sun.misc.Base64Decoder), but it's not specified and should not be used (especially as it's not required to exist in other implementations or even versions).

If you absolutely need to avoid third party libraries (Apache Commons Codec would be the traditional provider of a Base64 implementation), then you might want to copy a BSD (or similarly) licensed version into your project. There is a public domain implementation and that's about as painless as it gets, when it comes to licenses.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download