@Test public void testIsImage(){ System.out.println(ImageHelper.isImage(file+"/tgepng")); }
public static boolean isImage(String filePath) { File imageFile = new File(filePath); if (!imageFile.exists()) { return false; } Image img = null; try { img = ImageIO.read(imageFile); return img != null && img.getWidth(null) > 0 && img.getHeight(null) > 0; } catch (Exception e) { return false; } finally { img = null; } }
ImageHelper { public static boolean isImage(String filePath) { File imageFile = new File(filePath); if (!imageFile.exists()) { return false; } Image img = null; try { img = ImageIO.read(imageFile); return img != null && img.getWidth(null) > 0 && img.getHeight(null) > 0; } catch (Exception e) { return false; } finally { img = null; } } }
ImageHelper { public static boolean isImage(String filePath) { File imageFile = new File(filePath); if (!imageFile.exists()) { return false; } Image img = null; try { img = ImageIO.read(imageFile); return img != null && img.getWidth(null) > 0 && img.getHeight(null) > 0; } catch (Exception e) { return false; } finally { img = null; } }  }
ImageHelper { public static boolean isImage(String filePath) { File imageFile = new File(filePath); if (!imageFile.exists()) { return false; } Image img = null; try { img = ImageIO.read(imageFile); return img != null && img.getWidth(null) > 0 && img.getHeight(null) > 0; } catch (Exception e) { return false; } finally { img = null; } }  static boolean isImage(String filePath); static ResultBean pngCaptcha(int strlen, int width, int height, String file); static ResultBean pngCaptchaBase64(int strlen,int width,int height); static ResultBean gifCaptch(int strlen,int width,int height, String file); static ResultBean gifCaptchBase64(int strlen,int width,int height); }
ImageHelper { public static boolean isImage(String filePath) { File imageFile = new File(filePath); if (!imageFile.exists()) { return false; } Image img = null; try { img = ImageIO.read(imageFile); return img != null && img.getWidth(null) > 0 && img.getHeight(null) > 0; } catch (Exception e) { return false; } finally { img = null; } }  static boolean isImage(String filePath); static ResultBean pngCaptcha(int strlen, int width, int height, String file); static ResultBean pngCaptchaBase64(int strlen,int width,int height); static ResultBean gifCaptch(int strlen,int width,int height, String file); static ResultBean gifCaptchBase64(int strlen,int width,int height);  }