码迷,mamicode.com
首页 > 移动开发 > 详细

android判断文件是否是图片文件的方法

时间:2014-12-01 15:47:37      阅读:847      评论:0      收藏:0      [点我收藏+]

标签:android   io   sp   文件   on   bs   ef   new   nbsp   

判断一个文件是否是图片文件的方法,采用BitmapFactory去decode然后根据返回的Options参数来确定:

    public static boolean isImageFile(String filePath) {
        Options options = new Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(filePath, options);
        if (options.outWidth == -1) {
            return false;
        }
        return true;
    }

android判断文件是否是图片文件的方法

标签:android   io   sp   文件   on   bs   ef   new   nbsp   

原文地址:http://www.cnblogs.com/wuqinghua/p/4134980.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!