int totalNum = 9;
int batchCommitNumber=10;
int subListNum= totalNum/batchCommitNumber;
List<Integer> collect = IntStream.range(0, 9).boxed().collect(Collectors.toList());
for (int j = 0; j < subListNum+1; j++) {
int start=j*batchCommitNumber;
int end=(j+1)*batchCommitNumber;
if (j==subListNum) {
end=totalNum-1;
}
if (start>end) {
continue;
}
List<Integer> subList = collect.subList(j*batchCommitNumber, end);
if (j==subListNum) {
subList.add(collect.get(end));
}
mybatis批量插入list切割list算法
最新推荐文章于 2024-07-08 00:14:00 发布