如何使用java在google appengine中读取图像url [英] How to read a image url in google appengine using java

查看:20
本文介绍了如何使用java在google appengine中读取图像url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ImageIO 不在 GAE 的白名单中.如何在不使用 ImageIO 的情况下从 url 读取图像(JPG、PNG)作为 ImageBuffer?

The ImageIO is not in the whitelist of GAE. How to read a image(JPG,PNG) from url as ImageBuffer without using ImageIO?

推荐答案

您可以读取 url 流并使用 IOUtils 来自 apache commons.

You could read the url stream and create a bytearray using the IOUtils from apache commons.

URL url = new URL(this.url);
InputStream input = url.openStream();
byteArray = IOUtils.toByteArray(input)

注意:
toByteArray 方法在内部缓冲输入,因此不需要使用 BufferedInputStream.

Note:
toByteArray method buffers the input internally, so there is no need to use a BufferedInputStream.


BufferedImage 被列为 AppEngine 不支持;这意味着您不能在 Google App Engine 上使用该第三方库.


BufferedImage is listed as not supported on AppEngine; that means that you CAN'T use that third party library on Google App Engine.

这篇关于如何使用java在google appengine中读取图像url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆