JasperReport - 传递图片
2021-01-24 14:13
标签:url bim 文件 ble false tmp 注意 col lin JasperReport - 传递图片 标签:url bim 文件 ble false tmp 注意 col lin 原文地址:https://www.cnblogs.com/duchaoqun/p/13253404.htmlSummary
DemoA
URL url = new URL(microService + "/getQR?url=" + URLEncoder.encode(targetURL, ‘UTF-8‘)+"&width=400&height=400")
InputStream inputStream = url.openStream()
param.put("QRCode", inputStream)
DemoB
URL url = new URL("https://www.duchaoqun.cn/a.jpg")
InputStream inputStream = url.openStream()
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int n = 0;
while (-1 != (n = inputStream.read(buffer))) {
baos.write(buffer, 0, n);
}
baos.flush();
byte[] imageInByte = baos.toByteArray();
baos.close();
InputStream in11 = new ByteArrayInputStream(imageInByte);
BufferedImage bImageFromConvert = ImageIO.read(in11);
param.put("QRCode", bImageFromConvert)