http://nichehire.com/Nichehire/upload/img_job_photo_burhan393@gmail.com.jpg
我需要通过给定的 URL 知道图像是否存在。为此,我使用下面的代码。在下面的代码中,如果没有发生错误,我将返回 true,并且如果 URL 不包含图像,则将返回 false。但是上面给出的 URL 不包含图像,即使它返回 true。我的代码有问题吗?
public static boolean exists(String URLName) {
boolean result = false;
try {
InputStream input = (new URL(URLName)).openStream();
result = true;
} catch (IOException ex) {
System.out.println("Image doesnot exits :");
}
return result;
}