Java BufferedImage from String base64StringToImage(String imageString)

Here you can find the source of base64StringToImage(String imageString)

Description

base String To Image

License

Mozilla Public License

Declaration

public static BufferedImage base64StringToImage(String imageString) 

Method Source Code


//package com.java2s;
//License from project: Mozilla Public License 

import javax.imageio.ImageIO;

import java.awt.image.BufferedImage;
import java.io.*;
import java.util.Base64;

public class Main {

    public static BufferedImage base64StringToImage(String imageString) {
        BufferedImage image = null;
        byte[] imageByte;
        try {/*from   w w  w .j a  v  a  2  s. c o m*/
            imageByte = Base64.getDecoder().decode(imageString);
            ByteArrayInputStream bis = new ByteArrayInputStream(imageByte);
            image = ImageIO.read(bis);
            bis.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return image;
    }
}

Related

  1. base64StringToImage(String imageString)
  2. base64StringToImg(final String base64String)
  3. base64ToImage(final String data, final int width, final int height)
  4. base64ToImage(String base64)
  5. base64ToImg(String base64Strings)