Here you can find the source of output(BufferedImage image, OutputStream out)
public static void output(BufferedImage image, OutputStream out) throws IOException
//package com.java2s; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.OutputStream; public class Main { public static void output(BufferedImage image, OutputStream out) throws IOException { ImageIO.write(image, "JPEG", out); }/*from w w w . j av a 2 s. c om*/ }