I've a requirement to add multiple images to a output stream and display those images in JSF.
Ex code:
List<inputStream> images = list of inputstream - each image is one input stream
ByteArrayOutputStream stream = new ByteArrayOutputStream()
for(inputStream iStream: images){
stream.write(IOUtils.toByteArray(iStream);
}
return stream.toByteArray();
Now it is displaying only first Image but not displaying remaining images.
Please help me here to get pass multiple images and display in jsp.
You can try like this:
ByteArrayOutputStream stream = new ByteArrayOutputStream();
List<byte[]> imagesByteList = new List<byte[]>;
for(inputStream iStream: images){
stream.write(IOUtils.toByteArray(iStream);
imagesByteList.add(stream.toByteArray());
stream.reset();
}
return imagesByteList; // here you get all your image in bytes array form
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With