[英]How to download an animated gif picture with httpClient in java
我需要使用httpClient从Internet下载动画gif图片。 我用这种方法。
HttpResponse httpResponse = HttpClientUtils.getResponse(httpGet);
InputStream is = httpResponse.getEntity().getContent();
BufferedImage sourceImg = ImageIO.read(is);
ImageIO.write(sourceImg, "gif", file);
但是图片是静态的。
例如:
我想要:
其实:
实际图片是gif动画的第一张。
谢谢。
就像Gimby所说的那样,他是对的,不需要ImageIO!
InputStream is = httpResponse.getEntity().getContent();
byte[] bytes = IOUtils.toByteArray(is);
FileUtils.writeByteArrayToFile(new file(path),bytes);
谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.