过程:
1、该接口返回的为字节流,因此在调用过程中选择InputStream流接收接口返回值
2、拿到输入流后将其处理为base64字符串返回
实现:
public String dealInputStreamToBase64(InputStream in) {
try {
byte[] data = null;
ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
byte[] buff = new byte[100];
int rc = 0;
while ((rc = in.read(buff, 0, 100)) > 0) {
swapStream.write(buff, 0, rc);
}
data = swapStream.toByteArray();
return Base64Util.encode(data);
} catch (Exception e) {
log.info("=======接口返回输入流转换异常=====", e);
}
return "";
}



