public static boolean checkImageFile(final FileItem item){
  BufferedImage bi;
  InputStream is=null;
  try {
    is=item.getInputStream();
    bi=ImageIO.read(is);
  }
 catch (  IOException e) {
    return false;
  }
 finally {
    if (is != null) {
      try {
        is.close();
      }
 catch (      Exception e) {
      }
    }
  }
  return (bi != null);
}

public static boolean checkImageFile ( final FileItem item ) { BufferedImage bi ; InputStream is = null ; try { is = item . getInputStream ( ) ; bi = ImageIO . read ( is ) ; } catch ( IOException e ) { return false ; } finally { if ( is != null ) { try { is . close ( ) ; } catch ( Exception e ) { } } } return ( bi != null ) ; }
checks if image file is image .
