首页 > 编程语言 > 详细

java去除字符串中的特定字符

时间:2016-08-16 15:58:28      阅读:282      评论:0      收藏:0      [点我收藏+]
public static void updateFileNames(String url, String index){
        File file = new File(url);
        //判断文件目录是否存在,且是文件目录,非文件
        if(file.exists() && file.isDirectory()){
            File[] childFiles = file.listFiles();
            String path = file.getAbsolutePath();
            for(File childFile : childFiles){
                //如果是文件
                if(childFile.isFile()){
                    String oldName = childFile.getName();
                    String newName = oldName.substring(oldName.indexOf(index));
                    
                    childFile.renameTo(new File(path + "\\" +  newName));
                }
            }
        }
        

 

java去除字符串中的特定字符

原文:http://www.cnblogs.com/zhengchunhao/p/5776547.html

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