public byte[] getImageByte(String strUrl){
ByteArrayOutputStream baos = null;
try{
URL u = new URL(strUrl);
BufferedImage image = ImageIO.read(u);
baos = new ByteArrayOutputStream();
ImageIO.write( image, "jpg", baos);
baos.flush();
return baos.toByteArray();
}catch (Exception e){
log.error("通过url,将图片转字节数组错误,请检查!");
}finally{
if(baos != null){
try {
baos.close();
} catch (IOException e) {
log.error("关闭流失败!");
}
}
}
return null;
}