/** * @Desc : 切分list位多個固定長度的list集合(我這是業務需要,直接是1w條數據切分) * @Author : RICK * @Params: [historyList] * @Return: java.util.Map * @Date : 2017/10/26 18:30 */ public static Map spiltList(List<CsvVo> historyList) { int listSize = historyList.size(); int toIndex = 10000; Map map = new HashMap(); //用map存起來新的分組后數據 int keyToken = 0; for (int i = 0; i < historyList.size(); i += toIndex) { if (i + toIndex > listSize) { //作用為toIndex最后沒有100條數據則剩余幾條newList中就裝幾條 toIndex = listSize - i; } List newList = historyList.subList(i, i + toIndex); map.put(keyToken, newList); keyToken++; } System.out.println("一共切分了" + map.size() + "個list"); return map; }