//每批次大小
final static int BATCH_INSERT_SIZE = 7;
public static void main(String[] args) {
List<Integer> list = new ArrayList<>();
//模拟数据
for (int i = 0;i < 50;i++){
list.add(i);
}
int totalPageSize = list.size() % BATCH_INSERT_SIZE == 0 ?
list.size() / BATCH_INSERT_SIZE : list.size() / BATCH_INSERT_SIZE + 1;
for(int i = 0;i < totalPageSize ;i++){
//改为自己的批次处理逻辑即可
System.out.println(list.subList(i*BATCH_INSERT_SIZE,i == totalPageSize -1 ? list.size() :(i+1)*BATCH_INSERT_SIZE).size());
}
}
03-15
972
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
02-06
479
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-08
217
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)