it says,
You need to save the BufferedImage to a ByteArrayOutputStream using the ImageIO class, then create a ByteArrayInputStream from toByteArray().
well, how? i can't see any method in ImageIO returning a ByteArrayOutputStream.
second answer a bit more helpful but
buffer = ((DataBufferByte)(bufferedImage).getRaster().getDataBuffer()).getData();
throws,
ClassCastException occured : java.awt.image.DataBufferInt cannot be cast to java.awt.image.DataBufferByte
i don't really understand why handling streams in java is so confusing. i am also trying to zip multiple images into a response stream and it's another breathtaking pain. it definitely shouldn't be this hard i guess... i'm actually a .net guy for years and things are making a lot more sense and pretty straightforward with c#.