Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Byte array to vaadin image
How can I convert a byte array into a vaadin image, so that I can add this to a vaadin layout (it must be a vaadin component then)?
Solution:
public static Image convertToImage(final byte[] imageData)
{
StreamSource streamSource = new StreamResource.StreamSource() {
public InputStream getStream()
{
return (imageData == null) ? null : new ByteArrayInputStream(
imageData);
}
};
return new Image(
null, new StreamResource(
streamSource, "streamedSourceFromByteArray"));
}