List of usage examples for com.google.common.net MediaType parse
public static MediaType parse(String input)
From source file:org.inakirj.imagerulette.utils.ImageUtils.java
/** * Validate HTTP URI.//from w ww . j a v a 2s .co m * * @param uri * the URI * @return true, if given URI is an static image */ public static boolean isValidImageURI(String uri) { HttpURLConnection con; try { URL obj = new URL(uri); con = (HttpURLConnection) obj.openConnection(); String contentType = con.getContentType(); MediaType mt = MediaType.parse(contentType); return mt.is(MediaType.ANY_IMAGE_TYPE); } catch (Exception e) { return false; } }