首页 > 编程语言 > 详细

java中删除特定后缀名文件

时间:2016-06-12 10:50:12      阅读:322      评论:0      收藏:0      [点我收藏+]
String path = Environment.getExternalStorageDirectory()
                        .getPath() + AppConstant.FILE_PATH + "/" + apkName ;
                File file = new File(path);
deleteApk(path);
/**
         * 删除其他版本安装包
         */
        public void deleteApk(String abpath) {
            String[] ss = abpath.split("/");
            String name = ss[ss.length - 1];
            String path = abpath.replace("/" + name, "");

            File file = new File(path);// 里面输入特定目录
            File temp = null;
            File[] filelist = file.listFiles();
            for (int i = 0; i < filelist.length; i++) {
                temp = filelist[i];
                if (temp.getName().endsWith("apk") && !temp.getName().endsWith(name))// 获得文件名,如果后缀为“”,这个你自己写,就删除文件
                {
                    temp.delete();// 删除文件}
                }
            }
        }

 

java中删除特定后缀名文件

原文:http://www.cnblogs.com/chenlong-50954265/p/5576693.html

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