File file=new File("d:/a/aa/test.1.txt"); System.out.println(file.getName().replaceAll("[.][^.]+$", ""));