java对象列表分隔-数据库批量保存
package com.topcheer.zjgmanage.xw.util; import java.util.ArrayList; import java.util.List; /** * @ClassName lijinhao * @Description TODO * @Author zrc * @Date 2021/3/26 16:03 * @Version 1.0 */ public class XwJavaUtil { /** * @Author lijinhao * @Decription 以pageSise分隔List对象 * @Date 2021/3/26 16:38 * @Param [list, pageSize] * @return java.util.List<java.util.List<T>> **/ public static <T> List<List<T>> splistList(List<T> list, final int pageSize){ List<List<T>> listArray = new ArrayList<List<T>>(); List<T> subList = null; for(int i =0;i<list.size();i++){ if(i%pageSize ==0){ subList = new ArrayList<T>(); listArray.add(subList); } subList.add(list.get(i)); } return listArray; } }