首页 > 编程语言 > 详细

判断是否是图片,java实现

时间:2020-08-19 12:44:05      阅读:80      评论:0      收藏:0      [点我收藏+]

原文链接:

https://blog.csdn.net/u010002184/article/details/74227581

private static boolean isImage(File file) throws IOException {
		BufferedImage bi = ImageIO.read(file);
		if(bi == null){
		   return false;
		}
		return true;

  

// 0.2.内容校验
public void  method(MultipartFile file){
        try {
            BufferedImage image = ImageIO.read(file.getInputStream());
            if (image == null) {
                // 图片格式不正确
                throw new RuntimeException();
            }
        } catch (IOException e) {
            throw new RuntimeException("图片格式不正确!");
        }
}

  

判断是否是图片,java实现

原文:https://www.cnblogs.com/tuxiaoer/p/13527892.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!