Exemplo de saída para imagem JS
// Java side
BufferedImage image = ImageIO.read(new File("helloworld.png"));
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ImageIO.write(image, "png", outputStream);
String encodedImage = Base64.encode(outputStream.toByteArray());
// js side
<img src="data:image/png;base64,[ENCODED STRING GOES HERE]">
Cheerful Cassowary