30

Yes, I'm that stupid. I'm trying to stick some groovy code together from various cookbook recipes, and I can't get from an InputStream to BufferedImage in Java/Groovy. Google is not being my friend at present.

Dycey
  • 4,767
  • 5
  • 47
  • 86
  • I see your Google-foo is lacking Dycey-san. You must practice and make your sensei proud! – Möoz Oct 06 '14 at 01:26

1 Answers1

90
BufferedImage imBuff = ImageIO.read(object.getInputStream());

Should work...

Gans
  • 1,000
  • 7
  • 5
  • 2
    as I already had a stream variable, it was as simple as `BufferedImage imBuff = ImageIO.read(myInputStrVar);`. Yes, I am stupid! – Dycey Jun 24 '11 at 08:07
  • 7
    @Dycey No,you are not but he(Gans) is smart. – Moshi Apr 13 '14 at 20:13
  • 1
    note: do not close the stream, InputStream will not be null but imagebuffer will be a null. close it after the conversion. – 3xCh1_23 Feb 05 '16 at 20:46