ImageIO write to stream

I am attempting to write a png image to a stream before adding the stream to a mime mail message.

I am using the following code

[code]

ImageOutputStream mailImage;

try{

ImageIO.write(ActReport.EmailSetup(), "png", mailImage);

}

catch (IOException ew){

}

[code]

I am getting the following compile error message:

variable mailImage might not have been initialized

ImageIO.write(ActReport.EmailSetup(), "png", mailImage);

How do fix this.

[528 byte] By [sandyg9000a] at [2007-11-27 2:24:46]
# 1
initialize it?
ejpa at 2007-7-12 2:32:14 > top of Java-index,Core,Core APIs...
# 2
How do you initialize an Image stream?
sandyg9000a at 2007-7-12 2:32:14 > top of Java-index,Core,Core APIs...
# 3
http://java.sun.com/j2se/1.5.0/docs/guide/imageio/spec/title.fm.html
ejpa at 2007-7-12 2:32:14 > top of Java-index,Core,Core APIs...
# 4

Over the past three days I have read the spec many times. The examples show how to initialize files. I can not find how to specifically initialize an ImageOutputString. For example,

File f = new File("c:\images\myimage.png");

ImageIO.write(im, "png", f);

This code works for a file. My goal is to keep the BufferedImage data in the format of png in memory. Again the goal would be to read this information into a mimebodypart as image/png. Am I off base in this solution? Can someone provide code or a more specific reference to documentation. Is there a better approach?

sandyg9000a at 2007-7-12 2:32:14 > top of Java-index,Core,Core APIs...
# 5

> I can not find how to specifically initialize an

> ImageOutputString.

ImageOutputStream?

http://java.sun.com/j2se/1.5.0/docs/api/javax/imageio/ImageIO.html#createImageOutputStream(java.lang.Object)

> the goal would be to read this information into a mimebodypart as image/png

Surely you mean write this information ...? and surely all you need is http://java.sun.com/j2se/1.5.0/docs/api/javax/imageio/ImageIO.html#write(java.awt.image.RenderedImage,%20java.lang.String,%20java.io.OutputStream) ?

ejpa at 2007-7-12 2:32:14 > top of Java-index,Core,Core APIs...