截取文件名后缀和总页数的计算:
public class Test1 {
public static void main(String[] args) {
String fileName = "图片123.jpg";
if (fileName.lastIndexOf(".") > 0) {
String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
System.out.println("该文件的后缀名是:" + suffix);
}
int total = 123; //总条数
int pageSize = 10; //每页条数
int totalPage = (total % pageSize == 0 ? total / pageSize : total / pageSize + 1); //总页数
System.out.println("总页数为:" + totalPage);
}
}