码迷,mamicode.com
首页 > 编程语言 > 详细

数组拆分

时间:2016-12-28 02:20:36      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:pes   mat   raw   awt   key   int   ram   导出   param   



/**
 * 把大数据量的List拆分
 * @param bigList 需要导出的Excel数据
 * @param capacity 子List的最大存储数据量
 * */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static List getSplitList(List bigList,int capacity){
	List<List> splitList = new ArrayList<List>();
	//得到将要拆分的List的子List的数量
	int count = bigList.size()%capacity > 0 ? bigList.size()/capacity + 1 : bigList.size()/capacity;
	for(int i = 0;i < count;i++){
		List smallList = new ArrayList<>();
		for(int j =capacity*i;j<Math.min(capacity*(i+1), bigList.size());j++){
			smallList.add(bigList.get(j));
		}
		splitList.add(smallList);
	}
	return splitList;
}

数组拆分

标签:pes   mat   raw   awt   key   int   ram   导出   param   

原文地址:http://www.cnblogs.com/shenjichenai/p/6227969.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!