java获取文件后缀名(正则表达式)+文件名

String fileName="asadas.jsp";
        String reg = ".+(.JPEG|.jpeg|.JPG|.jpg|.png|.PNG)$";
        Matcher matcher =Pattern.compile(reg).matcher(fileName);
        System.out.println(matcher.find());

 

 public String[] simpleFile (String file){
            int sum = file.lastIndexOf(".");
            return new String[]{
                    file.substring(0, sum),
                    file.substring(sum + 1)
            };
        }

 

posted @ 2018-11-02 15:52  韦邦杠  阅读(14627)  评论(0编辑  收藏  举报