Here you can find the source of checkUrlImage(final String url)
public static boolean checkUrlImage(final String url)
//package com.java2s; //License from project: Open Source License import java.net.HttpURLConnection; import java.net.URL; public class Main { /** Blocking. Ensures the specified URL corresponds to an image. */ public static boolean checkUrlImage(final String url) { try {//from w ww . jav a 2 s.co m final HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); return connection.getResponseCode() == 200 && connection.getContentType() != null && connection.getContentType().contains("image"); } catch (Exception e) { return false; } } }