Adam Bien's Weblog
Base64 Encoding With JDK 1.6+ And Java 8
The method: javax.xml.bind.DatatypeConverter#printBase64Binary(byte) encodes a byte into a Base64 encoded string.
To encode a String with JDK 1.6+ use the static method
String encodedDuke = DatatypeConverter.printBase64Binary("duke".getBytes("UTF-8"));
Java 8 comes with the java.util.Base64 class entirely dedicated to Basic, URL, Filenames and MIMEs encoding and decoding.
See you at Java EE Workshops at MUC Airport!
Special Events: Java 8 with Java EE 7: "More Power with Less Code", 13th October, 2014 and Java EE 7: "Testing and Code Quality", 14th October, 2014 Tweet Follow @AdamBien