has anyone used JPEGImageEncoder successfuly?

Has anyone successfully used JPEGImageEncoder to create
JPEG files from BufferedImages, such as those returned
by DisplayImpl.getImage()?

The following code:

      OutputStream stream
        new FileOutputStream("jpeg_file");
      JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(stream);
      BufferedImage image = display.getImage(true);
      encoder.encode(image);

hangs in the call to encoder.encode().

Thanks,
Bill
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
hibbard@xxxxxxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html