Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static java.awt.image.BufferedImage decodeToImage(String imageString) {

        java.awt.image.BufferedImage image = null;
        try {
            String imgString = imageString.startsWith("data:image/")
                    ? imageString.substring(imageString.indexOf(',') + 1)
                    : imageString;
            java.io.InputStream stream = new java.io.ByteArrayInputStream(
                    java.util.Base64.getDecoder().decode(imgString));
            image = javax.imageio.ImageIO.read(stream);
            stream.close();
        } catch (Exception e) {
        }
        return image;
    }
}