if (format.equalsIgnoreCase("ppm")) PNMImage.write(image, stream); else ImageIO.write(image, format, stream);
BufferedOutputStream stream = null; try { stream = new BufferedOutputStream(new FileOutputStream(f)); write(image, format, stream); } finally { if (stream != null) stream.close(); }
	public static void write(BufferedImage image, String format, OutputStream stream)		throws IOException	{		if (format.equalsIgnoreCase("ppm"))			PNMImage.write(image, stream);		else			ImageIO.write(image, format, stream);	}