save Image - Java 2D Graphics

Java examples for 2D Graphics:BufferedImage Create

Description

save Image

Demo Code


//package com.java2s;

import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

public class Main {
    public static void saveImage(String filename, BufferedImage image) {
        File file = new File(filename);
        try {//from w ww . j  a v  a  2 s.c  om
            ImageIO.write(image, "png", file);
        } catch (Exception e) {
            System.out.println(e.toString() + " Image '" + filename
                    + "' saving failed.");
        }
    }
}

Related Tutorials