I am trying to convert any image format to a BMP format and then returning back the base64 String of the converted BMP byte. However when I am returning the BMP image base64 string, it is coming blank. I even tried printing it on console but still the string is not getting printed over the console. In debug mode I can see the image is getting converted to base64 string but its not getting printed or passed to further control. Below is the code snippet:
InputStream in = new ByteArrayInputStream(content);
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
BufferedImage image = ImageIO.read(in);
ImageIO.write(image, "bmp", out);
byte[] bt=out.toByteArray();
in.close();
out.flush();
out.close();
return new String (Base64.getEncoder().encodeToString(bt));
} catch (IOException | NullPointerException e) {
System.out.println("error while converting image"+e);
e.printStackTrace();
}
but dont know why return string is not getting added in response and tried pritintin it in console as well, still no output If i debug it the base64 string is getting generated but its not gteting pass. can anyone point out my mistake or help me on this.