I am trying to get a bytearray from bufferedImage, but the length of my ByteArrayOutputstream is always zero and I am not getting any bytes. This is what I do
any ideas why this doesn't work
BufferedImage scaledPicture = ..... ByteArrayOutputStream baos = new ByteArrayOutputStream( ); ImageIO.write(scaledPicture, extension, baos); baos.flush(); byte[] toByteArray = baos.toByteArray(); baos.close(); return toByteArray;
Any ideas?
Farouk alhassan
source share