如何使用java在谷歌appengine中读取图片网址 [英] How to read a image url in google appengine using java
本文介绍了如何使用java在谷歌appengine中读取图片网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在不使用ImageIO的情况下将图像(JPG,PNG)从url作为ImageBuffer读取?
解决方案
url流并使用创建一个bytearray IOUtils 来自apache commons。
URL url = new URL(this.url);
InputStream input = url.openStream();
byteArray = IOUtils.toByteArray(输入)
注意:
toByteArray
方法在内部缓冲输入,因此不需要使用 BufferedInputStream
。
编辑:
BufferedImage在AppEngine上不被支持;这意味着您不能在Google App Engine上使用该第三方库。
The ImageIO is not in the whitelist of GAE. How to read a image(JPG,PNG) from url as ImageBuffer without using ImageIO?
解决方案
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)
Note:
toByteArray
method buffers the input internally, so there is no need to use a BufferedInputStream
.
EDIT:
BufferedImage is listed as not supported on AppEngine; that means that you CAN'T use that third party library on Google App Engine.
这篇关于如何使用java在谷歌appengine中读取图片网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文