Here is an example based on your code:
byte[] btDataFile = new sun.misc.BASE64Decoder().decodeBuffer(base64);
BufferedImage image = ImageIO.read(new ByteArrayInputStream(btDataFile));
JOptionPane.showMessageDialog(null, "", "Image",
JOptionPane.INFORMATION_MESSAGE,
new ImageIcon(image));
I would recommend you to avoid using sun.misc.BASE64Decoder, like sun.* packages are not part of the supported, public interface, details here . You can easily switch to Base64 from Apache Commons, i.e.:
byte[] btDataFile = Base64.decodeBase64(base64);
BufferedImage image = ImageIO.read(new ByteArrayInputStream(btDataFile));
JOptionPane.showMessageDialog(null, "", "Image",
JOptionPane.INFORMATION_MESSAGE,
new ImageIcon(image));
source
share