/**
* 切割list方法
*
* @param origin
* @param size 按每份多少切割
* @param <T>
* @return
*/
public static <T> List<List<T>> divideListBySize(List<T> origin, int size) {
int block = (origin.size() + size - 1) / size;
return IntStream.range(0, block).
boxed().map(i -> {
int start = i * size;
int end = Math.min(start + size, origin.size());
return origin.subList(start, end);
}).collect(Collectors.toList());
}
切割list方法,按每份多少切割
最新推荐文章于 2024-08-23 00:40:55 发布