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.
You can write or download file from encoded Base64 string:
Base64 base64 = new Base64();
String encodedFile="JVBERi0xLjUKJeLjz9MKMSAwIG9iago8PCAKICAgL1R5cGUgL0NhdGFsb2cKICAgL1BhZ2VzIDIgMCBSCiAgIC9QYWdlTGF5b3V0IC9TaW5";
byte[] dd=encodedFile.getBytes();
byte[] bytes = Base64.decodeBase64(dd);
response.setHeader("Content-disposition", "attachment; filename=\""+filename+"\"");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "-1");
// actually send result bytes
response.getOutputStream().write(bytes);
Worked for me and hopefully for you also...