patternjavaCritical
Decode base64 data in Java
Viewed 0 times
base64datadecodejava
Problem
I have an image that is base64 encoded. How do I decode base64 in Java? Hopefully using only the libraries included with Sun Java 6.
Solution
As of v6, Java SE ships with JAXB.
UPDATE: JAXB is no longer shipped with Java (since Java 11). If JAXB is required for your project, you will need to configure the relevant libraries via your dependency management system, for example Maven. If you require the compiler (
javax.xml.bind.DatatypeConverter has static methods that make this easy. See parseBase64Binary() and printBase64Binary().UPDATE: JAXB is no longer shipped with Java (since Java 11). If JAXB is required for your project, you will need to configure the relevant libraries via your dependency management system, for example Maven. If you require the compiler (
xjc.exe) you also need to download that separately.Context
Stack Overflow Q#469695, score: 425
Revisions (0)
No revisions yet.