如何使用GWT检查图像的给定URL是否存在? [英] How can I check if the given URL of an image exists using GWT?

查看:72
本文介绍了如何使用GWT检查图像的给定URL是否存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查一个给定的URL是否存在,它是一个图像,以便从它创建一个新的图像(String url)。如果给定的URL不是图像,那么它应该返回一个错误。 你可以用 RequestBuilder - 请求图片URL,使用 Response getHeaders()获取内容类型的方法,并检查它是否为图像。


I want to check if a given URL exists and it's an image, in order to create a new Image(String url) from it. If the given URL is not an image then it should return an error.

解决方案

You could do this with a RequestBuilder -- just request the image URL, use the Response's getHeaders() method to get the content type, and check if it's an image.

这篇关于如何使用GWT检查图像的给定URL是否存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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