JAVA每次从List中取出100条记录⽅法⼀:
int listSize = customerIdList.size();
int toIndex = 1000;
for(int i = 0; i < customerIdList.size(); i += 1000){
if(i + 1000 > listSize) {
toIndex = listSize - i;
}
List<String> idList = customerIdList.subList(i, i + toIndex);
}
⽅法⼆:100个常量字符串
//每1000⼀批,分批处理
int batchCount = 1000;
int sourListSize = customerIdList.size();
int subCount = sourListSize % batchCount == 0 ? sourListSize / batchCount : sourListSize / batchCount + 1;
int startIndext = 0;
int stopIndext = 0;
for (int i = 0; i < subCount; i++) {
stopIndext = (i == subCount - 1) ? stopIndext + sourListSize % batchCount : stopIndext + batchCount;
List<String> idList = new ArrayList<>(customerIdList.subList(startIndext, stopIndext));
startIndext = stopIndext;
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论