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)
            };
        }

 

转载于:https://www.cnblogs.com/weibanggang/p/9895044.html

你可能感兴趣的:(java获取文件后缀名(正则表达式)+文件名)