imagewriter.java

来自「Python Development Environment (Python I」· Java 代码 · 共 35 行

JAVA
35
字号
package ch.hsr.ukistler.astgraph;

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

import javax.imageio.ImageIO;

public class ImageWriter implements Runnable {

	private BufferedImage img;

	private String fileName;

	public ImageWriter(BufferedImage img, String fileName) throws Throwable {
		if (img == null)
			throw new Exception("Image cannot be retrieved");
		this.img = img;
		this.fileName = fileName;
	}

	public void run() {
		FileOutputStream out;
		try {
			out = new FileOutputStream(new File(fileName));
			ImageIO.write(img, "png", out);
			out.flush();
			out.close();
		} catch (Throwable e) {

		}
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?