Decode Base64 data in Java

Ryan P picture Ryan P · Jan 22, 2009 · Viewed 762k times · Source

I have an image that is Base64 encoded. What is the best way to decode that in Java? Hopefully using only the libraries included with Sun Java 6.

Answer

Jeremy Ross picture Jeremy Ross · Jan 13, 2010

As of v6, Java SE ships with JAXB. javax.xml.bind.DatatypeConverter has static methods that make this easy. See parseBase64Binary() and printBase64Binary().